Skip to content

Instantly share code, notes, and snippets.

@whoacowboy

whoacowboy/Clear.php

Last active Oct 30, 2015
Embed
What would you like to do?
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