Sweep Laravel's Decks

When developing with Laravel, sometimes things just start acting real weird. An environment variable that you changed, has no effect. A route which should work, doesn’t, and many more.

Often, the issue is caused by caching and fixing it is as simple as clearing the various caches that exist.

Here are a series of commands you should try to see if your problem magically “goes away”.

1
2
3
4
5
6
php artisan clear-compiled
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
composer dump-autoload

Let’s take each in turn.

1
php artisan clear-compiled

This represents Laravel’s compiled class file and could be thought as its internal cache. As Matt Stauffer says in his Laravel Up and Running, book - start here.

1
php artisan cache:clear

This clears the application cache so all cached values are removed.

1
php artisan config:clear

This will remove all knowledge of your environment configuration values.

1
php artisan route:clear

This will ask Laravel to forget about all of your routes which, when cached, provide faster lookups.

1
php artisan view:clear

This removes knowledge about the views you have e.g. compiled blade files etc.

1
composer dump-autoload

This will update the autoloader and ensure it is aware of all packages available without a need to reinstall them etc.

If you still experience issues after this, then it’s time to go to DEFCON 2.


Hi! Did you find this useful or interesting? I have an email list coming soon, but in the meantime, if you ready anything you fancy chatting about, I would love to hear from you. You can contact me here or at stephen ‘at’ logicalmoon.com