Clear Cache with Artisan Command (CLI) - Laravel 9
Clear Cache with Artisan Command (CLI) - Laravel 9
Published Feb 12,2023 by Kailash Singh
0 Comment 1662 Views
In this tutorial, we are going to teach you, how to Clear Cache with Artisan Command (CLI).
Clear Route Cache in Laravel:
php artisan route:cache
Clear Application Cache in Laravel:
php artisan cache:clear
Clear Config Cache in Laravel:
php artisan config:cache
Clear View Cache in Laravel:
php artisan view:clear
Reoptimize Class:
php artisan optimize
Laravel clear cache without artisan:
Its not possible with shared hosting servers to access SSH there relying on artisan commands to clear, remove or delete cache in Laravel. However, there is one more trick in my book, and that is incorporating THE Artisan::call() method within the routes/web.php file with given below methods.
Example:
//Remove route cache
Route::get('/clear-route-cache', function() {
$exitCode = Artisan::call('route:cache');
return 'All routes cache has just been removed!';
});
//Remove config cache
Route::get('/clear-config-cache', function() {
$exitCode = Artisan::call('config:cache');
return 'Config cache has just been removed!';
});
//Remove application cache
Route::get('/clear-app-cache', function() {
$exitCode = Artisan::call('cache:clear');
return 'Application cache has just been removed!';
});
//Remove view cache
Route::get('/clear-view-cache', function() {
$exitCode = Artisan::call('view:clear');
return 'View cache has jut been removed!';
});
Comments ( 0 )
Elevenstech Web Tutorials
Elevenstech Web Tutorials helps you learn coding skills and enhance your skills you want.
As part of Elevenstech's Blog, Elevenstech Web Tutorials contributes to our mission of “helping people learn coding online”.
Read More
Newsletter
Subscribe to get the latest updates from Elevenstech Web Tutorials and stay up to date