Trying to deploy my updated Symfony2 application, I ran into the following problem.
(note that my application uses the new Symfony 3 directory structure. replace bin/console
with app/console
and var/cache
with app/cache
if you're using the current directory structure)
I have recently renamed one of my service classes (VariantSlugListener
). When deploying the application on the staging server, I got the following error when running bin/console assetic:dump --env=prod
:
PHP Fatal error: Class 'MyBundle\Listener\VariantSlugListener' not found in /var/www/example.com/staging/var/cache/prod/appProdProjectContainer.php on line 494
Line 494 of appProdProjectContainer.php
contains the following code:
return $this->services['3f288d4f09c9906944ba7e17358f669b942397baf9d79d5ff0737bb756df7023_1'] = new \MyBundle\Listener\VariantSlugListener();
It is no surprise that \MyBundle\Listener\VariantSlugListener
can not be found, since it has been renamed to \MyBundle\EventListener\VariantSlugSubscriber
with the latest update. The solution would be to simply clear Symfony's cache.
However, when trying to clear the cache (using bin/console cache:clear --env=prod
) I get the exact same error as with the assetic:dump
command. So I get an error because my Symfony cache is outdated, but I can not clear the cache because of the error.
I can probably get around this by manually deleting the contents of the var/cache
directory, but that doesn't feel like the best solution.
Am I missing something?