That guide doesn’t actually dictate how namespaces are named, just that ‘Alphabetic characters in vendor names, namespaces, and class names may be of any combination of lower case and upper case’.
It does dictate how class names and class constants should be named. Namespaces should just follow psr-0.
Any reason for this? Anything you plan to implement that couldn’t be done following the PSR? Or is there anything you don’t like about it?
To me, it looks very similar to the current CLogger (looking only at the interface).
the log level specific helpers are missing in CLogger
they define other log levels
the context array is missing in CLogger, but shouldn’t be hard to implement. The interpolation it provides seems handy, I often find myself writing log messages like “Something happened, reason was: ‘{$reason}’.”
the category is missing in the PSR. Not sure how this can be solved, maybe by using several logger instances (one per category).
Did you already decide how to access the logger functionality? Will it remain a static helper, or will there be instances? A quick search yesterday showed, that both log4php and monolog support a concept similar to categories (not sure if they can be nested though) and support or plan to support PSR-3.
Even if you don’t plan to use PSR-3 interfaces directly, it might be worth using an abstract logger class or an interface, so one can easily implement an adapter to a PSR-3 compatible logging framework.
In fact, I very much like the way yii allows us to configure log routes, filters and stuff. Not sure if I would switch to another logging framework even if I could. Also, it’s hard to argue without knowing what you’re coding.
And after reviewing how the logging currently works, I think it would be even possible to inject a 3rdParty logging framework in Yii 1.1. It’s basically the LogRouter that needed to be exchanged with an adapter.
I’ve read through this thread and found that the OP’s question is not really answered.
As PSR-0 does not dictate to use uppercase first letters for namespaces, but virtually every PHP project with namespaces - I’ve looked so far - uses UpperCase\FirstLetters, I really would like to know if \Yii will adopt this format also?
I would also suggest it, because it’s like an unwritten convention now.
I’m actually debating about both choices. If we choose to use CamelCase, how should we name the Yii static class? We would like it to be \Yii, which would confuse users with the \Yii namespace.
Usually namespaces follow the same naming conventions as the folder structure. I don’t know what you’ve have planned for the folder naming conventions in yii2 but I think that it would be great if it followed the same naming conventions as it’s predecessor. In other words it would be something like:
Many projects use a /src folder now to store their PHP classes, usually the autoloader maps this directory.
I think your example applies for the application directory (currently “protected”), “public” files are separated anyway and don’t have to follow these conventions.
At the moment I can think i.e. example of uploaded data and non-PHP scripts which go also into “protected”, but maybe it’s time to refactor the protected structure.
I know that the existing one is a very slim implementation and very useful for running your app out-of-the-box from your default webserver root, but I won’t sacrifice so much for it.
@schmunk: This has nothing to do with "protected" or "src".
How would you name your view files and view directories? And what about data directories, etc.?
@Chris83: The current implementation of Yii 2 uses the namespace format like you wrote (same as Yii 1.1). Here we are debating whether we should adopt CamelCase in namespace in Yii 2. So far, I’m most concerned with the mixed use of cases in directory names: class directories use CamelCase, while non-class directories use lower-case, which doesn’t look good to me.