I current have the following composer.json file:
{
"require": {
"slim/slim": "2.*"
},
"autoload": {
"psr-0": { "App": "app/" }
}
}
I'm trying to instantiate a class in the app folder, but the autoloader is looking for:
/var/www/framework/app//App/App.php
Obviously the second parameter is the folder containing the namespace rather than the root of the namespace. How can I make it load:
/var/www/framework/app/App.php
Thanks in advance!
The easiest solution is to rename the folder from app
to App
and set
"psr-0": { "App": "." }
I guess else you need a custom autoloader. However, I recommend to follow some proven use-cases:
src/App/App.php
with
"psr-0": { "App": "src" }
Looks curious, but I must say, that I would never call a namespace or class (or even both) just App
;) It doesn't say anything and with aliasing (use MyApplication as App
) there is no reason anymore to write as short identifiers as possible.