Often, developers stuck after running Artisan commands. Here, we will show you how to resolve an error after php artisan config:cache in Laravel. Are you ready? Let’s go then.
How We Got an Error?
Our team was working on a very large project. The project was hosted in Virtual Machine & Vagrant in local.
At some point, the team wanted to change some configuration in .env file. So they did change and try to verify the change, but they don’t get any effect.
So they google it and found a command “php artisan config:cache” which used to create a cache file for faster configuration loading. But after running that command they got some error as follows. Your story might be different than us and your error might be different. We are listing all possible errors as following.
Error One => Fatal error: Uncaught ReflectionException: Class config does not exist Error Two => InvalidArgumentException in FileViewFinder.php line 137: View [welcome] not found.
You can simply run the following command from your command-line tool to get rid of two above mentioned errors.
$ php artisan config:clear
php artisan config:clear is used to remove the configuration cache file. Then you can again run php artisan config:cache command to recreate the configuration cache file.
This might be an interesting solution for you. Try this in a situation when you are not able to run the commands.
php artisan config:cache stores cached files in bootstrap/cache/config.php. So you get rename or remove that file. Now, go and test your application. It should be resolved.
That’s it. We hope this post helped you to resolve error after php artisan config:cache in Laravel.
Please let us know in the comments if everything worked as expected or your issues or any questions. If you think this article saved your time & money, please do comment, share, like & subscribe. Thank you for reading the post 🙂