Code snippets for symfony 1.x


clear the cache without symfony command line interface

Some PHP code to clean the cache very useful when you don't have access to symfony "command line interface" on production server.

file: symfony_cc.php

function deltree($f)
  $sf = realpath($sf);
  if (is_dir($f)) {
    foreach(glob($f.'/*') as $sf) {
      if (is_dir($sf) && !is_link($sf)) {
        if (is_writable($sf)) {
          echo 'Delete dir.: '.$sf."\n";
      } else {
        if (is_writable($sf)) {
          echo 'Delete file: '.$sf."\n";
  } else {
    die('Error: '.$f.' not a directory');
echo '<pre>';
echo 'Clean symfony cache'."\n";
echo "\n";
echo '</pre>';
by Olivier LOYNET on 2008-03-11, tagged cache  cli 

Comments on this snippet

gravatar icon
#1 Sylvain PAPET on 2008-03-11 at 12:07

Tu réinvente la roue, there is already symfony tools to do it : sfToolkit::clearGlob

it is usefull for backend in order to delete template cache when products, news or any content are updated. Example, to delete all templates cache of frontend app : sfToolkit::clearGlob(sfConfig::get('sf_root_cache_dir').'/frontend//template//all');

see :