PSR-2. When to capitalize directories?
As I understood according to the PSR-2 standard, we have to use the names of the directories containing the classes. But how do you do this if the directory also contains some other files, such as styles and scripts?
Let's say I have a plugin directory, each plugin can contain templates and other things:
plugins
PluginName // lowercase?
PluginName.php // Contains base class "PluginName"
templates
home.tpl
css
css.css
js
js.js
PluginName2
....
Is this structure correct?
source to share
You can name your directories whatever you want.
However, if you intend to automatically load your PHP classes using PSR-0 or PSR-4, the directory names affected by the corresponding part of the class name must match exactly.
PSR-2 does not make any assumptions or give rules as to when a class name or namespace should exist.
PSR-1 states in Chapter 3 : "Class names must be declared in StudlyCaps". However, this only affects the filename of the file containing such a class. If you're using PSR-4 autoloading, you can still avoid using any part of the namespace altogether in the path if you define the entire map Name\Space -> directory/for/that/namespace
for each directory containing code.
PSR-1 has no rules regarding the formatting of the namespace, so you can also avoid using uppercase letters there, and because of this, avoid using uppercase letters in the directory path.
Note that both PSR-0 and PSR-4 autoload are case sensitive when it comes to mapping a namespace / class to a file path and file. So in the end you will end up with a case-sensitive filesystem layout.
Also note that most namespaces also use StudlyCaps, and I find the use of lowercase letters to be unusual.
source to share