user2540463
user2540463

Reputation: 112

Symfony - Duplicate class definition in cache

I've created a very simple Symfony (3.4) project, with only one api that prints out a static json.

When i run that api for the first time everything works fine, but from second time i got this error:

(1/1) FatalErrorException
Compile Error: Cannot redeclare class Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser
in ControllerNameParser.php (line 24)

This is why inside cache/{env}/classes.php that class was redefined. In fact, clearing cache turn api to work, but again only for the first time.

How can I solve the issue? I think could be something related to composer.json autoload, here the snip

    "autoload": {
    "psr-4": {
        "AppBundle\\": "src/AppBundle",
        "MyCompany\\TypeBundle\\": "src/MyCompany/TypeBundle"
    },
    "classmap": [
        "app/AppKernel.php",
        "app/AppCache.php"
    ]
},

Thanks in advance

Upvotes: 2

Views: 890

Answers (1)

Yury Yagupov
Yury Yagupov

Reputation: 31

i had the same problem. and as i see, the team of symfony is fix that.

try to do this: in composer.json change version from 3.4.* to 3.3.* and composer update symfony/symfony than change 3.3.* to 3.4.* back and composer update symfony/symfony

for me it fix the problem. try.

Upvotes: 3

Related Questions