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


#22

If you have class with FQN like Foo\Bar\Baz, then Foo is not a framework name, it is a vendor name. And in case of Yii framework the vendor is Yiisoft, not Yii. You should be aware of that, since you’re installing yiisoft/yii2, not yii/yii2.


(Serban Cristian) #23

I am. I mean, i am using Yii for quite a while. The idea is that new people have no clue about who yiisoft is. I won’t get into more details about this, but i really hope from all the above your takeaway is not this.

Another point against this naming convention is people that will have yii2 projects and yii3 projects in parallel, switching between the projects will add extra cognitive load without reasons.

Anyway, that’s my 2 cents related to the issue and i think it’s pretty clear it would be a silly move, but up to you.


#24

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.


(Sidney Lins) #25

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.


(Ziggi) #26

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


(Lubosdz) #27

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.


(Alexander Makarov) #28

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.


#29

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.


(Amjad Mughal) #30

My vote for Yii


(Sizemail) #31

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


(Knight Yoshi) #32

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.


(Mehdi Achour) #33

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)


(Flávio Veloso) #34

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?).

(Alexander Makarov) #35

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.


(Alexander Makarov) #36

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


(muitosefala) #37

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


(Flávio Veloso) #38

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:).


(Alexander Makarov) #39

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