Get "PHP 8 in a Nuthshell" (Now comes with PHP 8.3)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

Clear all kinds of caches with a single command in Laravel

There are mainly three kinds of caches in Laravel that you need to clear all the related junk files and optimize the performance of the application.

Individually clearing caches

Here are all the caches and their related artisan command to clear them up.

  • To flush the application cache
$ php artisan cache:clear
  • To flush the route cache file
$ php artisan route:clear
  • To flush the configuration cache file
$ php artisan config:clear

These commands are fine but I recently got to know about a command that can do all these single-handedly. Thanks to this tweet by Andrew Schmelyun!

One command fits all!

There’s a optimize:clear artisan command that can flush/remove the application cache, route cache, and config cache altogether.

$ php artisan optimize:clear

So, if you’re going to remove all the caches and don’t want to do it individually, you can use this command happily!

Learn the fundamentals of PHP 8 (including 8.1, 8.2, and 8.3), the latest version of PHP, and how to use it today with my new book PHP 8 in a Nutshell. It's a no-fluff and easy-to-digest guide to the latest features and nitty-gritty details of PHP 8. So, if you're looking for a quick and easy way to PHP 8, this is the book for you.

Like this article? Consider leaving a


👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.