Laravel 12 Clear Cache, Route, Config, Event Command

Hey there! In this article, I’ll show you how I clear different types of cache in Laravel 12 using simple artisan commands. Whether you're stuck with outdated routes, configs, or views, these commands help reset everything in just a second.

This is something I often do while developing Laravel apps — especially after making config changes or updating routes. Let’s go through each one.

Laravel 12 Clear Cache, Route, View, Config, Event Artisan Command

Laravel 12 Clear Cache, Route, Config, Event Command

1. Clear Application Cache

php artisan cache:clear

This clears the application cache stored in storage/framework/cache.

 

2. Clear Route Cache

php artisan route:clear

Use this when you’ve updated your routes and they’re not reflecting.

 

3. Clear Config Cache

php artisan config:clear

Useful after updating environment variables or config/*.php files.

 

4. Clear View Cache

php artisan view:clear

This clears compiled Blade templates from storage/framework/views.

 

5. Clear Event Cache

php artisan event:clear

If you’ve cached your events and listeners using event:cache, use this to clear them.

 

6. Clear All Caches

If you want to quickly reset everything, run all commands at once:

php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan event:clear

// OR

php artisan optimize:clear

You can also make a custom artisan command or bash alias to speed it up.

 

7. Clear Cache by Route

Route::get('clear-cache', function() {

    Artisan::call('cache:clear');
  
    dd("Cache Clear Successfully");
});

Hope this helped! Bookmark it so you don’t have to search next time. 😄

 


You might also like:

techsolutionstuff

Techsolutionstuff | The Complete Guide

I'm a software engineer and the founder of techsolutionstuff.com. Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers. Explore Laravel, PHP, MySQL, jQuery, Bootstrap, Node.js, Vue.js, and AngularJS in our tech stack.

RECOMMENDED POSTS

FEATURE POSTS