39 lines
857 B
PHP
39 lines
857 B
PHP
#!/usr/bin/env php
|
|
<?php
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
if (php_sapi_name() !== 'cli') {
|
|
die();
|
|
}
|
|
|
|
function cleanDir($path)
|
|
{
|
|
$directoryIterator = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
|
|
$iteratorIterator = new RecursiveIteratorIterator($directoryIterator, RecursiveIteratorIterator::CHILD_FIRST);
|
|
foreach ($iteratorIterator as $file) {
|
|
if ($file->getFilename() !== '.gitkeep') {
|
|
$file->isDir() ? rmdir($file) : unlink($file);
|
|
}
|
|
}
|
|
}
|
|
|
|
$action = isset($argv[1]) ? $argv[1] : 'all';
|
|
|
|
switch ($action) {
|
|
case 'cache':
|
|
cleanDir('resources/cache');
|
|
break;
|
|
case 'sessions':
|
|
cleanDir('resources/sessions');
|
|
break;
|
|
case 'all':
|
|
cleanDir('resources/cache');
|
|
cleanDir('resources/sessions');
|
|
break;
|
|
case 'help':
|
|
default:
|
|
echo 'Usage: php ' . $argv[0] . ' <cache|sessions|all|help>' . PHP_EOL;
|
|
}
|
|
|
|
exit(0);
|