在使用Symfony 3.3.1的项目中,我有几个“自制”的bundle,我使用composer.json导入指定存储库,这样:
"repositories": [
{ "type": "git", "url": "git@github.com:MyCompany/CoreBundle.git" },
...
],
在同一个项目中,在src文件夹中我有另外一个Bundle,如下所示:
src/MyCompany/Bundle/OtherBundle
现在,在我的开发环境中(Vagrant with Ubuntu 14.04,php 7.1,composer 1.5.2)它完美无缺 . 但在 生产环境 (完全相同的操作系统,PHP和作曲家版本)上,我收到此错误:
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "MyCompanyOtherBundle" from namespace "MyCompany\Bundle\OtherBundle".
在composer.json中,我为psr-4尝试了几种配置,所有这些配置在dev中工作正常但不在prod中:
"psr-4": {
"MyCompany\\": "src/MyCompany/"
},
要么
"psr-4": {
"": "src/"
},
要么
"psr-4": {
"MyCompany\\Bundle\\OtherBundle": "src/MyCompany/Bundle/OtherBundle"
},
在完成所有这些更改之后,我运行了composer dump-autoload,但它没有任何效果 .
有关这是怎么回事吗?提前致谢