I started to write a new app I grabbed the latest Symfony code, which happened to be the newly released Symfony 2.5.0. After going through to normal steps to get it setup I tried loading it via my browser and got a blank page.
There was no output in the browser, but the Apache error logs showed this:
PHP Fatal error: Cannot redeclare class Symfony\\Component\\HttpKernel\\EventListener\\SessionListener in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/SessionListener.php on line 24
What the heck…? I did some more digging trying to debug this and ran into another error:
PHP Fatal error: require(): Cannot redeclare class symfony\\component\\httpkernel\\event\\getresponseevent in vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php on line 154
Some more debugging and I found these:
PHP Fatal error: Class 'Symfony\\Component\\Debug\\ExceptionHandler' not found in vendor/symfony/symfony/src/Symfony/Component/Debug/Debug.php on line 46 PHP Fatal error: Class 'Debug' not found in web/app_dev.php on line 21 PHP Fatal error: Class 'Symfony\\Bundle\\FrameworkBundle\\DependencyInjection\\Compiler\\ProfilerPass' not found in vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php on line 68 PHP Fatal error: Class 'Symfony\\Bridge\\Doctrine\\DependencyInjection\\AbstractDoctrineExtension' not found in vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php on line 34
At this point I’m getting a bit concerned there is something with my server or something more severe. These errors aren’t consistent and seem to randomly be popping up…
After a bit of frantic checking of my other sites, server logs, apache logs, and others it dawns on me I have APC on…I tried turning it off and viola, it works.
With Symfony 2.5.0 APC seems to be used by default whereas this wasn’t the case before.
I was already running behind on my project so I haven’t looked into disabling APC for dev yet, but that would be a better solution that turning it off.
TLDR: APC is likely the cause of inconsistent errors that don’t make much sense in a fresh Symfony 2.5.0 install.
I hope I am able to save someone the trouble of debugging this like I had to. If you know a better solution to resolving this than turning APC off please mention that in the comments.
Social