Fix “Cannot redeclare class Symfony…” in Symfony2 after upgrade

After upgrading from Symfony 2.2 to 2.3 I got this error in my application:

Fatal error: Cannot redeclare class SymfonyComponentHttpFoundationFileBag in app/cache/prod/classes.php on line 1823

Another symptom was this error while trying to clear the cache for the prod environment:

[SymfonyComponentDependencyInjectionExceptionInvalidArgumentException]
The parameter "kernel.http_method_override" must be defined.

The process to solve this problem was:

1.- Remove the cache folder:

rm -rf app/cache/prod

2.- Then clear the cache for the prod environment:

php app/console cache:clear --env=prod --no-debug

Ref: Symfony2 Google Group

You might also like

Symfony2 – ErrorException: Notice: serialize() [function.serialize]: “xxx” returned as member variable from __sleep() but does not exist in …
While storing an entity from Doctrine2 in the session under a Symfony2 application I got this error:ErrorException:...

Symfony2 – ErrorException: Notice: serialize() [function.serialize]: “xxx” returned as member variable from __sleep() but does not exist in …
While storing an entity from Doctrine2 in the session under a Symfony2 application I got this error:ErrorException:...

Symfony2 – ErrorException: Notice: serialize() [function.serialize]: “xxx” returned as member variable from __sleep() but does not exist in …
While storing an entity from Doctrine2 in the session under a Symfony2 application I got this error:ErrorException:...

Fix The parameter “debug.error_handler.throw_at” must be defined in Symfony2
If you get this error when trying to clear a Symfony2 application cache:$ php app/console cache:clear...

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.