DEV Community

loading...

Laravel Clear Cache Using Artisan

Robert Look
I'm a Web Application Developer with 6 years of experience. Currently, I'm working on front-end & back-end web developm
・1 min read

In This tutorial Simply clear cache from the command line (CLI). we will discuss how to clear cache from blade (views), routes, config, etc using the (CLI) and artisan command.

we need to make cache in laravel projects for better completion. But if our application is development mode then what we want to get cured due to the cache. Then this time we need to clear the cache.

//Clear route cache:
 Route::get('/route-cache', function() {
     $exitCode = Artisan::call('route:cache');
     return 'Routes cache cleared';
 });

 //Clear config cache:
 Route::get('/config-cache', function() {
     $exitCode = Artisan::call('config:cache');
     return 'Config cache cleared';
 }); 

// Clear application cache:
 Route::get('/clear-cache', function() {
     $exitCode = Artisan::call('cache:clear');
     return 'Application cache cleared';
 });

 // Clear view cache:
 Route::get('/view-clear', function() {
     $exitCode = Artisan::call('view:clear');
     return 'View cache cleared';
 });
Enter fullscreen mode Exit fullscreen mode

laravel clear cache

Discussion (0)