PSR-4 autoloading with Composer
There are two ways to fix it.
-
change
composer.json
to"Portal\\Core\\": "src/core/"
Or rename the
core
directory toCore
https://getcomposer.org/doc/04-schema.md#psr-4
The subdirectory name MUST match the case of the sub-namespace names.
http://www.php-fig.org/psr/psr-4/
Related videos on Youtube
Fractaliste
French IT engineer. Prefered language : Java Prefered framework : Laravel Prefered solver : Choco Prefered metasyntactic variable : plop Prefered quote : There are 10 kind of people on the world, those who understand binary, and those who don't. If needed, you can contact me on : fractaliste at gmail dot com
Updated on July 09, 2022Comments
-
Fractaliste almost 2 years
I run a portail with composer's autoloading class system:
"autoload": { "psr-4": { "Portal\\": "src/" } }
It works when I run
composer.phar dump -o
, for instance my class Boostrap is well referenced intovendor/composer/autoload_classmap.php
file:'Portal\\Core\\Bootstrap' => $baseDir . '/src/core/Bootstrap.php',
But when I don't run the optimized option on autoload dumping, the autoloading system doesn't works anymore:
Fatal error: Class 'Portal\Core\Bootstrap' not found in /var/www/portail/prod/web/index.php on line 7
How can I make autoloading works without
-o
option?