Lowercase or CamelCase namespaces?

Historically Yii used lowercase namespaces such as:

namespace yii\caching;

While it conforms to PSR coding style guides (they do not regulate it), majority of PHP packages use CamelCase namespaces such as:

namespace Yii\Caching;

That, when many packages are used in Yii project, causes naming inconsistencies.

Which of the following do you prefer?

  • Keep lowercase namespaces
  • Switch to CamelCase namespaces

0 voters

I really love the lowercase form, but since the repo-split for Yii 3, I don’t like having \yii\activerecord for a package named active-record.


Note that Yii namespace conflicts with Yii class. yii does not.

1 Like

Although lowercase is nice, the question is really about multiple words namespace. As @machour said, we are forced to write namespaces linking words without spaces.

So: Yii\ActiveRecord or yii\activerecord ?

I prefer the first.

P.S. Otherwise yii\activeRecord ?

@CeBe potentially we’ll be able to get rid of Yii::.

1 Like

Then would be alternative syntax?

For me CamelCase namespaces are historical leftovers from PSR-0 autoloading rules, where namespace was part of the class name (so it should follow class name naming conventions) and change from SomeVendor_SomeClass to SomeVendor\SomeClass was natural. But there is no real reason to promote CamelCase namespaces, while there are reasons to not use it (it is easier to distinguish between namespace and class name when they follow different naming conventions). Changing this for Yii gives no benefits, only increases the amount of work needed to upgrade from Yii 2 to Yii 3.


:+1: this does not only apply to yii vs. Yii but also to e.g. yii\db\QueryBuilder as the class but there may also be a yii\db\querybuilder namespace that contains helper classes.

I do not see any problem with current namespace naming, what are the reasons to change it?


Lowercase in namespaces more familiar. Most of packages from packagist.org use lowercase. I think it’s easy to perceive use section when every item has the same style.

1 Like

Till what time this poll will remain open? I mean to say when can we see the finally accepted way for namespace

Decision is not going to be made by the poll result, poll should only give an idea of overall preference. Decision should be made based on arguments given.


I think most of packagist packages use CamelCase namespaces, not lowercase.

1 Like

I personally prefer lowercase (or snake_case) everywhere it is possible for its better readabilty and ease of typing

As said before, lowercase directory names and namespaces make it much easier to distinguish what’s a namespace and what’s a Class.


CamelCase for consistency with other popular packages & frameworks, and because snake_case for multiple words is ugly.

1 Like

this may not be as important, but php docs also uses camel case in its examples, so it may be a bit confusing for new yii adopters, also concerning multiple word I am in favor of camel case

I’d like to keep lowercase for namespaces. For ease to use and PSR conformity.
That the PHP website uses CamelCase is their problem :slight_smile: They probably did it before lowercase became the thing, and then keep doing it because they didn’t think to change it.

If Yii goes with CamelCase, then we’ll see naming conflicts, making it both more cumbersome to type and to use.


I’d prefer CamelCase because

  • most of packagist.org packages use it
  • it’s MuchMoreReadable than somecoolnamespace

The alternative is someCoolNamespace - it should not be less readable than CamelCase since (probably) most of names in your code already follows this convention.

Both lowercase and CamelCase are PSR-compatible. Also I think that CamelCase is used more than lowercase nowadays.

1 Like