Symfony autoload not working for a custom Bundle

浪尽此生 提交于 2019-12-13 03:16:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!