Skip to content

Instantly share code, notes, and snippets.

@steve-todorov
Created November 18, 2015 22:48
Show Gist options
  • Save steve-todorov/d92d595504c719500acd to your computer and use it in GitHub Desktop.
Save steve-todorov/d92d595504c719500acd to your computer and use it in GitHub Desktop.
A way to easily clear symfony cache without wiping out absolutely everything from the cache/ENV directory.
<?php
class MyController extends Controller {
public function myAction() {
$finder = new Finder();
/**
* @var SplFileInfo $file
*/
foreach($finder->name('*ProjectContainer*')->depth(0)->in($this->getParameter('kernel.cache_dir')) as $file){
unlink($file->getRealPath());
}
$cache = $this->get('cache_warmer');
$cache->enableOptionalWarmers();
$cache->warmUp($this->getParameter('kernel.cache_dir'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment