I have a project that have multiple subfolders. In one of the folders they are some "addons". All of these addons have a composer.json and a vendor-folder. I now wanted to build my own addon and created a new folder and put a composer.json
into that directory. composer install
works without any problems, but when I'm somehow installing my addon I'm getting the error
FastCGI: server "/fcgi-bin-php5-fpm-ezi" stderr: PHP message: PHP Fatal error: Call to undefined method Composer\\Autoload\\ClassLoader::setPsr4()
What could cause this problem? I already did composer dump-autoload
and composer global update
, because I found these solutions on the internet, but it still doesn't work. Do I have to do something special to make it work in sub-folders?
This is currently my composer.json
{
"name": "namespace/projectname-addonname",
"autoload": {
"psr-4": {
"namespace1\\namespace2\\namespace3\\" : "src"
}
}
}
I don't know if that helps, but when I var_dump
the loader this is the result
object(Composer\Autoload\ClassLoader)#138 (4) {
["prefixes":"Composer\Autoload\ClassLoader":private]=>
array(0) {
}
["fallbackDirs":"Composer\Autoload\ClassLoader":private]=>
array(0) {
}
["useIncludePath":"Composer\Autoload\ClassLoader":private]=>
bool(false)
["classMap":"Composer\Autoload\ClassLoader":private]=>
array(0) {
}
}
After that the $loader->setPsr4
method is called and I'm getting the fatal error.
The strange thing is, that when using classmap
instead of psr-4
for autoloading, it works without any problems.
composer --version
? – KitchenComposer version 1.0-dev (6eb50623e6e00bac4ed893802836e50b62c83434) 2016-02-08 19:03:10
and same problem – Carpenter