问题
In a project with Symfony 3.3.1 I have several "self-made" bundles I import with composer.json specifying the repositories, this way:
"repositories": [
{ "type": "git", "url": "git@github.com:MyCompany/CoreBundle.git" },
...
],
In the same project, in the src folder I have another Bundle like so:
src/MyCompany/Bundle/OtherBundle
Now, in my dev enviroment (Vagrant with Ubuntu 14.04, php 7.1, composer 1.5.2) it works perfectly. But on production (exactly same versions of OS, PHP and composer) I get this error:
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "MyCompanyOtherBundle" from namespace "MyCompany\Bundle\OtherBundle".
In the composer.json I tried several configurations for the psr-4, all of them work fine in dev but not in prod:
"psr-4": {
"MyCompany\\": "src/MyCompany/"
},
or
"psr-4": {
"": "src/"
},
or
"psr-4": {
"MyCompany\\Bundle\\OtherBundle": "src/MyCompany/Bundle/OtherBundle"
},
I ran the composer dump-autoload after on all of those changes but it had no effect.
Any idea on how this is happening? Thanks in advance
来源:https://stackoverflow.com/questions/47126081/symfony-autoload-not-working-for-a-custom-bundle