Created
October 23, 2015 10:15
-
-
Save wdmtech/2ec736043b80409781fe to your computer and use it in GitHub Desktop.
Quick 'n dirty Laravel 5 view (blade) cache, session file cache and debugbar cache delete command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
use Illuminate\Filesystem\Filesystem; | |
class ClearCaches extends Command | |
{ | |
/** | |
* The name and signature of the console command. | |
* | |
* @var string | |
*/ | |
protected $signature = 'clear:caches'; | |
/** | |
* The console command description. | |
* | |
* @var string | |
*/ | |
protected $description = 'Clear view (blade) caches, debugbar caches and sessions.'; | |
/** | |
* The file system instance. | |
* | |
* @var \Illuminate\Filesystem\Filesystem | |
*/ | |
protected $files; | |
/** | |
* Create a new command instance. | |
* | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
parent::__construct(); | |
$this->files = new Filesystem; | |
} | |
/** | |
* Execute the console command. | |
* | |
* @return mixed | |
*/ | |
public function handle() | |
{ | |
// View cache files | |
foreach ($this->files->files(storage_path('framework/views')) as $file) | |
{ | |
$this->files->delete($file); | |
} | |
$this->info('View cache files deleted'); | |
// Session cache files | |
foreach ($this->files->files(storage_path('framework/sessions')) as $file) | |
{ | |
$this->files->delete($file); | |
} | |
$this->info('Session cache files deleted'); | |
// Debugbar cache files | |
foreach ($this->files->files(storage_path('debugbar')) as $file) | |
{ | |
$this->files->delete($file); | |
} | |
$this->info('DebugBar cache files deleted'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment