Reputation: 21
I'm using Symfony 2 and working with wamp server. After some time, i cannot access my pages anymore with that exception always showing, can't figuring why. Here's the full stack trace :
in DebugClassLoader.php line 203
at DebugClassLoader->loadClass('Symfony\\Component\\HttpFoundation\\ParameterBag')
at spl_autoload_call('Symfony\\Component\\HttpFoundation\\ParameterBag') in Request.php line 240
at Request->initialize(array(), array(), array(), array(), array(), array([...]), null) in Request.php line 222
at Request->__construct(array(), array(), array(), array(), array(), array([...]), null) in Request.php line 1964
at Request::createRequestFromFactory(array(), array(), array(), array(), array(), array([...])) in Request.php line 281
at Request::createFromGlobals() in app_dev.php line 27
It seems the "DebugClassLoader" class is using reflection to analyze what's wrong and it throws an exception when getting to the ParameterBag class. A var_dump() shows that ParameterBag is implementing \IteratorAggregate and \Countable as expected but also some random class "o" which i can't figure where it comes from.
Prod environment will be an apache server running on a debian, maybe it will work on it but I'd better fix this on my current environment before going live.
All the code I have which may deal with ParameterBag is something like that :
$session = $request->getSession();
$session_id = $session->getId();
$webclient = $em->getRepository('AppBundle\Entity\WebClient')
->findOneBy(array("session_id" => $session_id));
...
Also note that clearing the cache does not fix this issue. (using php bin/console cache:clear [--env=dev])
PS: restarting apache fixes it, but it shows again later
Upvotes: 2
Views: 820
Reputation: 3801
Update PHP version and restart the apache server.
Currently, there are three supported versions of PHP i.e Versions 5.6, 7.0, 7.1and 7.2. As a modern-day web developer who works on different frameworks, packages need to have the multiple versions of PHP installed on your VPS.
During your development, not all your projects may support the latest version (V. 7.2) resulting you to downgrade to a much earlier version. In this tutorial, we will illustrate how to switch between the different versions of PHP from 7.2 to 7.0 to enable you to run your projects smoothly.
Upvotes: 0
Reputation: 1426
If you while debugging try to clear server cache. You will face some error like:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 2444952 bytes) in C:\xampp\htdocs\project_name\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.php on line 163
so to solve this issue you need to add below line in your php.ini and restart apache.
apc.cache_by_default = 0
Now see the magic. It will work fine.
thanks,
Anirudh Sood.
Upvotes: 0
Reputation: 21
APC was not enabled. I tried to find if any other cache was installed to disable them but there was not. It still occurs on my dev environment.
However it does not seem to happen on my prod environment. I'll probably work with it.
Upvotes: 0
Reputation: 1497
I had that problem (not on ParameterBag but same exception in the same file), it was caused by a corrupted installation of APC. Try putting this line in your php.ini :
apc.cache_by_default = 0
In the [APC]
block. If the error is gone for good, consider removing and reinstalling APC.
Upvotes: 1