Clearing Symfony Cache

I’m currently working on a Symfony2-based project which makes also use of the great JMSSecurityExtraBundle by Johannes Schmitt, in order to address method security authorization.

Everything work fine, but deploying in production, I ran into this problem:

1
2
3
% app/console cache:clear --env=prod
Clearing the cache for the prod environment with debug false
PHP Fatal error:  Cannot redeclare class EnhancedProxy_.... on line 64

I spent a lot of time digging Google, the problem seems very hard to solve at its origin, but I found this simple workaround: without any further arguments, the cache:clear command also tries to warm-up the cache and it seems that causes the problem.

By splitting the two operations, everything worked (at least for me!).

1
2
3
4
% app/console cache:clear --env=prod --no-warmup
Clearing the cache for the prod environment with debug false
% app/console cache:warmup --env=prod
Warming up the cache for the prod environment with debug false

Hope this saves someone some time.

Comments