Created
May 2, 2013 09:25
-
-
Save basdek/5501165 to your computer and use it in GitHub Desktop.
Clear cache from Controller in Symfony2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// asume controller context here | |
public function cccAction() | |
{ | |
$kernel = $this->get('kernel'); | |
$application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel); | |
$application->setAutoExit(false); | |
$options = array('command' => 'cache:clear',"--env" => 'prod', '--no-warmup' => true); | |
$application->run(new \Symfony\Component\Console\Input\ArrayInput($options)); | |
return new Response(); | |
} | |
?> |
crearing dev
My solutions are:
exec("php bin/console cache:clear --env=prod");
or
$fs = new Filesystem();
$fs->remove($this->getParameter('kernel.cache_dir'));
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to run this from within a command (not a controller), but it keeps clearing the
dev
cache, in spite of specifying'--env' => 'prod'
in the options array. Symfony 2.8.