Laravel Clear Cache Using Artisan Command (CLI)

Let’s start to laravel cache clear from the command line (CLI), In this laravel Post, I will know how to clear cache from blade (views) files, web routes, Configuration (config), or many more using the terminal(command line) with PHP artisan command.

When our Web application is product mode (live), I required to create a cache in laravel web projects for better completion. But if our web application is development mode then what I want to do is not get occurred due to the cache. At this time I required to clear the cache.

List of the cache clear commands, see Following

Many times you face an issue that any changes or updation to the Laravel web application are not reflecting on web interfaces. This occurred due to the web application is being served by the cache. This Article will use you to clear the cache in the Laravel application.

cache folder in laravel,clear cache in php,clear bootstrap cache laravel,php code to clear browser cache,laravel cache,how to clear bootstrap cache in laravel,php artisan refresh,clear composer cache,composer clear cache
cache clear in laravel
  1. Clear Route Cache
  2. Clear Cache in Application
  3. Clear Config Cache
  4. Clear View Cache
  5. Reoptimized Class
  6. Clear Configuration Cache

Clear Route Cache

You can easy to Use the Following command as well clear your main web routes cache :

php artisan route:cache

Clear Cache Laravel Application

You can easy to Use the Following command as well clear your app cache :

php artisan cache:clear

Laravel Clear Config Cache

You can easy to Use the Following command as well clear your config cache :

php artisan config:cache

You can easy to use config:clear to clear the config cache of the Laravel web app.

php artisan config:clear

Clear View Cache Laravel

Use the Following command and clear your view (blade) cache : Also, you may need to clear compiled view files of your application. To clear compiled laravel resource blade file layout view files run the following command from the terminal(CMD).

php artisan view:clear

Reoptimized Class

php artisan optimize

I do not retrieve SSH on shared hosting web servers, then I can also clear the cache by copy and paste the source code in route file. as well as last step to Go to your web.php file and put simple copy and paste Following Full source code for clear cache of your web application :

Clearing Caches in Laravel (Browser)

routes/web.php file

Route::get('/kill-all-caches', function() {
Artisan::call('cache:clear');
return "Good Luck Your All Caches is cleared";
});

How to Clear cache in Laravel 7/6/5?

There are the Following The simple About Clearing Route, View, Config Caches in Laravel 5,6,7 Full Information With Example and source code with route file.

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

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

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

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

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about cache clear Tutorials.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment