I'm building a framework (this is a vast simplification -- please don't recommend using an existing framework instead, that's not helpful) into which I would like to be able to integrate other libraries.
The PSR-0 recommendation suggests that all files within each sub-namespace be contained within their own specific directory. To keep things less complex for users of my framework, I would like to keep everything in one namespace, but organize the files into directories.
If PHP libraries can register their own autoloaders with spl_register_autoload()
, then why is it essential that this directory structure be adhered to? Is it feasible/permissable to simply eschew PSR-0, use my own autoloader for my classes, and then use (for example) Symfony's autoloader for any Symfony classes that I may make use of?
There's nobody forcing you to adhere to the standard. Sure, you can make your own autoloader and use it.
The specification was most likely created in an attempt to make libraries easier to understand, with the idea that if all code uses the same structure, then anyone should be able to instantly know where to go to find a certain class.
Following standards has certain advantages, such as:
A disadvantage might be that you might not like the standard. If that's the case, then you should weigh in the advantages as well when deciding whether or not to follow it.