Skip to content

Instantly share code, notes, and snippets.

@ma2thieu
Created February 29, 2012 17:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ma2thieu/1942649 to your computer and use it in GitHub Desktop.
Save ma2thieu/1942649 to your computer and use it in GitHub Desktop.
script to delete Symfony2 cache folder from the browser
<?php
// --- cache location
$cache_dir = dirname(__FILE__) . '/../app/cache';
echo "<b>cache_dir : $cache_dir</b>";
// ---
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
$o = $dir . "/" . $object;
if (filetype($o) == "dir") {
rrmdir($dir."/".$object);
}
else {
echo "<br/>" . $o;
unlink($o);
}
}
}
reset($objects);
rmdir($dir);
}
}
function cc($cache_dir, $name) {
$d = $cache_dir . '/' . $name;
if (is_dir($d)) {
echo "<br/><br/><b>clearing " . $name . ' :</b>';
rrmdir($d);
}
}
if (is_dir($cache_dir)) {
if (basename($cache_dir) == "cache") {
echo "<br/><br/><b>clearing cache :</b>";
cc($cache_dir, "dev");
cc($cache_dir, "prod");
cc($cache_dir, "test");
echo "<br/><br/><b>done !</b>";
}
else {
die("<br/> Error : cache_dir not named cache ?");
}
}
else {
die("<br/> Error : cache_dir is not a dir");
}
?>
@fintara
Copy link

fintara commented Feb 3, 2015

Thanks, very helpful!

@mostefamed
Copy link

Thanks a lot, helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment