symfony: [3.4] Cannot redeclare class Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4.*
PHP version 5.6.25

Stacktrace

We’re currently upgrading a Symfony project to 3.4 on PHP 5.6.25 and my colleague has been having this issue since I’ve added the following block of code to our AppKernel::registerContainerConfiguration method:

        $loader->load(function (ContainerBuilder $container) {
            $container->setParameter('container.autowiring.strict_mode', true);
            $container->setParameter('container.dumper.inline_class_loader', true);
            $container->addObjectResource($this);
        });

It only happened on a second request, and often it had to be a different request, not just the same one (aka refresh didn’t cause it).

He found two ways to make it work :

  1. Commenting out the line $container->setParameter('container.dumper.inline_class_loader', true);, or
  2. Commenting out the line $kernel->loadClassCache(); in app_dev.php

I personally can’t reproduce the issue on my setup. Any idea what might be happening here ?

Also, it might look like we’re not the only ones : https://stackoverflow.com/questions/47617879/symfony-duplicate-class-definition-in-cache

Thanks for your help. gnutix

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 5
  • Comments: 15 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Thx for the fix @nicolas-grekas. We just crashed the all Meetic website due to this error. 😃 I guess we will wait for the 4.4.2 to be release before upgrading to sf 3.4.

His 1st way is ok for me, i can refresh without error. The solution on stackoverflow doesn’t work for now…