Chris R Chris R - 8 months ago 64
PHP Question

Using Composer's Autoload

I have been looking around the net with no luck on this issue. I am using composer's autoload with this code in my


"autoload": {
"psr-0": {"AppName": "src/"}

But I need to autoload at a higher level than the vendor folder.

Doing something like this does not work:

"autoload": {
"psr-0": {"AppName": "../src/"}

Does anyone know a fix or how I can do this?


Every package should be responsible for autoloading itself, what are you trying to achieve with autoloading classes that are out of the package you define?

One workaround if it's for your application itself is to add a namespace to the loader instance, something like this:


$loader = require 'vendor/autoload.php';
$loader->add('AppName', __DIR__.'/../src/');