Skip to content

Instantly share code, notes, and snippets.

@msurguy
Created May 8, 2014 07:05
Show Gist options
  • Save msurguy/62158555be9f4a98378f to your computer and use it in GitHub Desktop.
Save msurguy/62158555be9f4a98378f to your computer and use it in GitHub Desktop.
Clean temporary folders
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class CleanDirs extends Command {
protected $name = 'cleandirs';
protected $description = 'Cleans directories.';
public function __construct()
{
parent::__construct();
}
public function fire()
{
$now = time();
foreach(File::directories('public/uploads/temp') as $dir ){
$dirtime = filemtime($dir);
if( $now-$dirtime > 3600){
File::deleteDirectory($dir);
$this->info('Directory '.$dir.' was deleted');
}
}
}
protected function getArguments()
{
return array(
array('example', InputArgument::OPTIONAL, 'An example argument.'),
);
}
protected function getOptions()
{
return array(
array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment