Use `Yiisoft` as a root namespace instead of `Yii` for Yii 3 packages

They literally just installed yiisoft/* package, expecting namespaces started from yiisoft should be natural (most of packages works in this way, convention used in yiisoft/yii2 was quite unnatural in this matter).
Also Yii 3 will not be just a framework like in case of Yii 1 and Yii 2, it will be more like ecosystem of libraries, which can be used with any framework/stack. Using framework-agnostic namespace may actually help in adoption of some packages, since there will be no confusion like “hey, I’m using Laravel in my project, I should not use this Yii library because it is a different framework”.

Actually I think it will help, since it will be easier to notice difference between Yii version used in application. Yii 3 will require different approach for writing code than Yii 2, so you need to switch context anyway - the more obvious difference will be, the less WTFs you will get.

2 Likes

Namespaces and classes MUST follow an “autoloading” PSR: [PSR-0, PSR-4].

This means each class is in a file by itself, and is in a namespace of at least one level: a top-level vendor name.

(Source: https://www.php-fig.org/psr/psr-1)

So, I am for use Vendor\Foo, Yiisoft\Foo.

Yii3 - a perfect match for a handy but meaningful name!

I would not care about installing two frameworks at the same time - that’s rare and temporary scenario.
Introducing new namespacing scheme for each major release is not good idea.
Simply keeping namespace yii is still best IMHO - it’s short and unique.

If you use Yiisoft now, then what would be next global namespace for major release to distinguish? Introducing Yiisoft does not solve anything.

BTW - for better orientation it would be perfect to keep framework versioning synced, e.g. namespace yii3 for version 4.x.x would be just confusing.

Yiisoft is about making root namespace a vendor name. Since we now have libraries that could be used separately from the framework, it makes sense.

1 Like

There will be no change in namespace in next major release, since Yii 4 will not be complete rewrite - only evolution with some BC breaks. That was the point of removing number from package name - ability to make major release which will not be different framework.

1 Like

My vote for Yii

no matter on char length to type or pronounce in namespace.

I think this is the only actual objective reasoning for this. The rest are just preferences.
Given this reasoning, I’d be fine with Yiisoft as the root namespace.

What about creating an alias in Composer, for Yiisoft/yii to yii? This way everyone gets their cake and can eat it too.

People are free to do so in their own composer files.
Also, some namespaces don’t have Yii in them, only Yiisoft.

See samples here: https://yii3.idk.tn/site/packages

(Red ones still needs to be properly namespaces)

I’d vote for Yii:

  • It is shorter
  • I fail to see a use case for real, production, websites to be running two different major version of the Framework. Dev/research is okay, but I assume those people know what they’re doing
  • “Yii” is the open-source framework’s name, whereas “Yiisoft” is short for a limited liability company (at least that’s what pops up as the first result in Google - https://github.com/yiisoft). This might hinder contribution from developers concerned about Yii being (or becoming in the future) an open-core package. I fail to see why there must be a “vendor name” in the namespace (although “Yii” could very well be the “vendor name”, and if you disagree, then for consistency it should be YiiSoftware – which is even uglier – shouldn’t it?).

Yiisoft is already adopted: https://github.com/yiisoft/docs/blob/master/004-namespaces.md

LLC thing was done a long long time ago to protect the name. We’re going to change it to e.V. non-commercial foundation as soon as we’ll have enough time for it.

1 Like

As for the naming, vendor namespace is now handy to distinguish framework-specific packages (Yiisoft\Yii) from geneal purpose ones (Yiisoft\Cache).

1 Like

I agree with @samdark, yiisoft looks good to me, i had some early thoughts and was feeling as @flaviovs, but i changed my mind, because it makes a lot of sense, and yii is needed inside, unless yiisoft do not code more than yii code itself, and for all to remember there is yii1 and yii2, bootstrap4, and so on so what I see:

YIISOFT
      |— YII 
      |   |— CORE
      |   |— DI
      |   |— ...
      |  
      |— Yii2
      |— Yii1
      |     
      | —yiiBootstrap3
      | —yiiBootstrap4
      |—...
      |— Common code to all versions
      |— What else 

We all have good ideas but they are centered on ourselves views and purposes, we commonly forget about other persperctives and needs, thats normal and fine, but in result, the core team know better how they should structure all this for allOfUs purpose, and they have standards to follow as well.

Cheers

I personally don’t care, but I’ve seen people refraining to contribute to open source projects backed by commercial business, hence my concern. As long as this LLC thing is cleared out, I think YiiSoft it is fine (okay, that’s one or two more visits to the SHIFT key, but I’m okay with that :slightly_smiling_face:).

We have to keep it for now because of name protection :frowning:

Will it be possible to run Yii3 and Yii2 simultaneously in one application? This is important for me (and for all bigger projects). Name of the root namespace is less important…

Yes. It should be possible.

loading different bootstrap file for different url prefix

I agree with you and vote for Yii too. Open source is the main argument.