xxxxxxxxxx
//CLEAR-CACHE
Route::get('/xclean', function() {
$exitCode1 = Artisan::call('cache:clear');
$exitCode2 = Artisan::call('view:clear');
$exitCode3 = Artisan::call('route:clear');
$exitCode4 = Artisan::call('config:cache');
dd('CACHE-CLEARED, VIEW-CLEARED, ROUTE-CLEARED & CONFIG-CACHED WAS SUCCESSFUL!');
});
xxxxxxxxxx
php artisan view:clear
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan optimize
xxxxxxxxxx
php artisan view:clear
php artisan config:clear
php artisan route:clear
php artisan cache:clear
php artisan clear-compiled
xxxxxxxxxx
/*
|=========================================================
| How to clear cache in laravel using route file
|=========================================================
*/
// LINK STORAGE
Route::get('/artisan/link-storage', function () {
Artisan::call('storage:link');
return "Done - storage linked";
});
// CLEAR CACHE
Route::get('/artisan/clear-cache', function() {
Artisan::call('cache:clear');
return "Done - cache are cleared";
});
// CLEAR ROUTES
Route::get('/artisan/route-cache', function() {
Artisan::call('route:cache');
return "Done - routes cache are cleared";
});
// CLEAR VIEWS
Route::get('/artisan/views-clear', function() {
Artisan::call('view:clear');
return "Done - views are cleared from cache";
});
xxxxxxxxxx
// Keep life simple :)
sail artisan optimize:clear
or
php artisan optimize:clear
// Output: Cached events cleared!
"
Compiled views cleared!
Application cache cleared!
Route cache cleared!
Configuration cache cleared!
Compiled services and packages files removed!
Caches cleared successfully!
"
xxxxxxxxxx
$ php artisan view:clear
$ php artisan config:clear
$ php artisan route:clear
$ php artisan cache:clear
$ php artisan clear-compiled
xxxxxxxxxx
php artisan route:clear
php artisan config:clear
php artisan cache:clear
xxxxxxxxxx
//we can use this route by only single click from admin panel or by accessing url
Route::get('/cache/clear', function() {
Artisan::call('cache:clear');
Artisan::call('config:clear');
Artisan::call('route:clear');
Artisan::call('view:clear');
return redirect()->route('admin.dashboard')->with('cache','System Cache Has Been Removed.');
})->name('admin-cache-clear');
#Or if any one want to clear cache from command then:-
/** Clear all cache Laravel **/
php artisan route:clear &&
php artisan view:clear &&
php artisan config:clear &&
php artisan cache:clear &&
php artisan clear-compiled
/** Short **/
php artisan optimize:clear //for all clear in a single command