November 18, 2007
This simple shell script allow remove log or tmp files from /tmp folder.
<?php
/**
*
*
* PHP versions 4 and 5
*
* Copyright (c) Tomenko Yevgeny
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
*/
class CleanShell extends Shell {
function help() {
$this->out(‘CakePHP Clean:’);
$this->out(“cake clean logs - Clean log files”);
$this->out(“cake clean cache - Clean models and persistent files”);
$this->hr();
}
function initialize() {
return true;
}
function __clean($path) {
$folder=& new Folder($path);
$tree=$folder->tree($path, false);
foreach ($tree as $files) {
foreach ($files as $file) {
if (!is_dir($file)) {
$file=& new File($file);
$file->delete();
}
}
}
return ;
}
function logs() {
$this->__clean(TMP . ‘logs’);
$this->out(‘Logs cleaned.’);
}
function cache() {
$this->__clean(TMP . ‘cache’ . DS . ‘models’);
$this->__clean(TMP . ‘cache’ . DS . ‘persistent’);
$this->out(‘Cache cleaned.’);
}
/**
* Handles CLI calls for the deploy task
*
* @param array $params
* @return unknown
*/
function main() { //$params
$this->help();
}
}
?>
November 19, 2007 at 5:25 am
[...] Clean fast, clean easy… « Cake Explorer’s Weblog Cleans out the log and cache directories (tags: cakephp cache log utility) Posted by Richard@Home Filed in 15 [...]