3 ms·
An eCommerce framework called Magento did a similar thing, it made for some fantastically long class names, but I was never left wondering where something lived
by ehnto 5y ago
An eCommerce framework called Magento did a similar thing, it made for some fantastically long class names, but I was never left wondering where something lived and autocomplete was never confused. They did this with underscores because namespaces didn't exist back then, but namespace based autoloading is essentially the same thing. PHP passes the autoloader function the full namespaced string `\Some\Namespaced\Class` and you do your directory traversal based on that inside the autoload function.
PHP makes it pretty easy to have multiple custom autoloaders too, which I've used to help bring legacy projects into modern times before. Even inside older frameworks with no awareness of classes, you can register an autoloader and start using the classes and namespaces in your module/plugin. When PHP runtime detects an unknown class, it will go through every autoloader function registered with spl_autoload_register.