Question

I'm refering to https://getcomposer.org/doc/01-basic-usage.md#autoloading

Probably all of the composer-users will add this into the composer.json to make it load custom namespaces:

{
    "autoload": {
        "psr-4": {"Acme\\": "src/"}
    }
}

In my case my folder structure is completely the same as the namespaces, so \hello\world would refer to a class inside \hello\world. So, is there a way to tell composer he should search inside the directory with the same names like the namespaces, without telling it inside the composer.json? It's unnecessary expense!

Was it helpful?

Solution 2

You can do it with a custom autoloader, since PHP can handle multiple autoloaders!

OTHER TIPS

No, you can't do that.

If you want to use long paths resembling the exact namespace structure of your class, you can always use PSR-0 instead, which forces you to use these long directory names. But note that this has some slight drawbacks - traversing longer paths takes slightly more time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top