Skip to content

Instantly share code, notes, and snippets.

@whoacowboy
Last active October 30, 2015 21:25
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 whoacowboy/94ceae12f07431ac6ded to your computer and use it in GitHub Desktop.
Save whoacowboy/94ceae12f07431ac6ded to your computer and use it in GitHub Desktop.
Artisan command to clear all caches
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class Clear 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 all caches and remove compiled views.';
/**
* Create a new command instance.
*
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->line('php artisan cache:clear');
$this->comment('(Flush the application cache)');
$this->call('cache:clear');
$this->line('php artisan route:clear');
$this->comment('(Remove the route cache file)');
$this->call('route:clear');
$this->line('php artisan clear-compiled');
$this->comment('(Remove the compiled class file)');
$this->call('clear-compiled');
$this->line('php artisan config:clear');
$this->comment('(Remove the configuration cache file)');
$this->call('config:clear');
$this->line('php artisan view:clear');
$this->comment('(Clear all compiled view files)');
$this->call('view:clear');
$this->line('composer dump-autoload');
exec('composer dump-autoload');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment