![]() |
|
Snippets |
|
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
<?php function deltree($f) { $sf = realpath($sf); if (is_dir($f)) { foreach(glob($f.'/*') as $sf) { if (is_dir($sf) && !is_link($sf)) { deltree($sf); if (is_writable($sf)) { echo 'Delete dir.: '.$sf."\n"; rmdir($sf); } } else { if (is_writable($sf)) { echo 'Delete file: '.$sf."\n"; unlink($sf); } } } } else { die('Error: '.$f.' not a directory'); } } echo '<pre>'; echo 'Clean symfony cache'."\n"; echo "\n"; deltree('../../cache'); echo '</pre>';
Comments on this snippet
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 : http://www.symfony-project.org/book/1_0/12-Caching