- Published on
How to clear cache in laravel
- Authors
- Name
- Jignesh Sanghani
- @jignesh19961020
To clear cache in laravel login to terminal using ssh and cd too larvel root directory. this tutorial will help you to clear your cache and which cache will removed.
- Clear Application cache To clear application cache run following command
php artisan cace:clear
- Clear Route cache To clear route cache run following command
php artisan route:clear
- Clear Config cache To clear configuration cache run following command
php artisan config:clear
- Clear View file cache To clear views cache run following command
php artisan view:clear
If you want to clear all cache in one command then make one artisan command for your self then run it. For example
php artisan clear:all
<?php
namespace AppConsoleCommands;
use IlluminateConsoleCommand;
class ClearAll extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'clear:all';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Clear all laravel cache';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
public function handle()
{
Artisan::call('cache:clear');
$this->info('Application cache is cleared.');
Artisan::call('config:clear');
$this->info('Configuration cache is cleared.');
Artisan::call('route:clear');
$this->info('Route cache is cleared.');
Artisan::call('view:clear');
$this->info('View cache is cleared.');
}
}