0

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

petekaner
  • 8,071
  • 5
  • 29
  • 52
  • Duplicate psr-4 definitions – Mike Doe Nov 05 '17 at 20:08
  • @mike sorry, didn't wrote it properly, those were different attempts I did – petekaner Nov 05 '17 at 20:26
  • The last one your "MyCompany\\Bundle\\OtherBundle" should ends with "\\" so it become "MyCompany\\Bundle\\OtherBundle\\" – Mohamed Radhi Guennichi Nov 05 '17 at 21:08
  • You defined the repository, but did you require it so the composer can download it to the vendors directory? In the autoload section you only define local namespaces. Please read composer documentation thoroughly. This topic has nothing to do with Symfony since the composer file is simply incorrectly crafted. – Mike Doe Nov 06 '17 at 03:23
  • 1
    @petekaner Have you found a solution? I'm stuck with the same problem... Thank you – Gianluca78 Jan 03 '18 at 11:37

0 Answers0