Many Laravel site users come across the dreaded “Whoops, looks like something went wrong.” error message when mirgating or upgrading their site or software.
Here at Bobcares, Our Support Engineers maintain hundreds of Laravel sites of web hosts, web designers, online publishers, and more.
In these sites, we’ve seen a wide range of reasons for this error that ranges from misconfigured .env
file to messed up PHP engines.
But many of these errors could just be the stale config cache that was left over from the old site.
So, a quick cache clearing can get your site back online.
How to use Artisan in Laravel to clear config cache
Before we get into the details, here’s a quick reminder of what these terms mean:
What is Artisan?
Artisan is a command line tool provided with Laravel to administer your web app code.
If your site was setup for you by a developer, it’s best to leave Artisan alone.
For this tutorial, you only need to know one command.
What is Laravel Config Cache?
Part of why developers love Laravel is because of its modular nature.
Many devs create modules for each function in the site, and store their configuration in separate config files.
All these configuration files are stored under the config
directory.
But having to read through all config files can slow down the site.
Laravel provides a way to merge all config options into one file to speed up the website.
This is done using the command php artisan config:cache
AFTER the code is deployed and the .env
file is created.
Why should you clear the configuration cache?
Some configuration entries (such as database name or file paths) could be server dependent, and sometimes after migration (or upgrade), these entries can change.
You might change these values in the configuration file, but Laravel could still refer to the old values.
So, it’s best to just clear it.
How do delete cached Laravel config file
This is the point where you’ll need to use your command line access and execute this command:
php artisan config:clear
Now, if you don’t know how Artisan works or are unfamiliar with command line, click here to get a Laravel admin to do it for you.
If you are on a Shared Hosting account, or if you do not have the privileges to execute that command, you can delete the cached config file.
It is located at bootstrap/cache/config.php
.
Bonus tip : How to clear application cache
Sometimes, it’s not the stale configuration entries that cause the “Whoops, looks like something went wrong.” error.
We’ve seen incompatible entries in the application cache also playing spoil sport.
So, it’s a good idea to clear that as well.
Again, head over to the command line interface, and issue this command:
php artisan cache:clear
If your site’s error is related to cache, these two commands should fix it.
Go ahead and reload the site.
None of this worked!
OK, don’t worry. There are a lot of other reason why Laravel could be failing.
If you need a quick solution, click here to consult our Laravel administrators. We are online 24/7 and can get on your case within a few minutes.
However, we would suggest that you consider getting a Server Administrator for your company who can monitor your server, perform falwless upgrades, and keep your server fast & secure.
If you need to talk to us about your site, click here to send us a mail.
0 Comments