Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Last active April 28, 2019 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreymcmahon/bedfbd5fa481df8a55ee4c03dffb9183 to your computer and use it in GitHub Desktop.
Save coreymcmahon/bedfbd5fa481df8a55ee4c03dffb9183 to your computer and use it in GitHub Desktop.
Demonstration of a Laravel console command.
<?php
namespace App;
use Illuminate\Console\Command;
class CleanTempCommand extends Command
{
protected $signature = "app:clean-temp";
protected $description = 'Clears out the temporary files folder.';
public function handle()
{
$unlinked = 0;
foreach (glob("storage/tmp/*.*") as $file) {
unlink($file);
$unlinked++;
}
$this->info("\nUnlinked {$unlinked} files."
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment