Symfony2 – Clear cache from a ContainerAware

If you application plays with some basic settings like, changing a template, or I don’t know any other reason that changes something in the application and then requires a cache clear, this is what you need.


$app_path = $this->container->getParameter('kernel.root_dir') . '/console' ;
$process = new \Symfony\Component\Process\Process("php $app_path cache:clear --env=prod --no-debug");
$process->run();

http://dev.dbl-a.com/symfony-2-2/symfony2-clear-cache-from-a-containeraware/