If you encounter a error message that says "file_put_contents: Failed to open stream: No such file or directory" in Laravel, here is what you should do.
What happened to my Laravel project
My XAMPP had a problem and never started again. So, I installed a new XAMPP into my PC and moved my Laravel project directory from my old XAMPP to a new one. Then I saw this error message.
Why this error message is shown?
This error message is shown when directories/files/classes are missing in the paths where they were supposed to be by moving directories, changing file names or deleting class names.
Execute these commands
1. php artisan cache:config
In order to speed up processing, Laravel creates cache files according to the settings in .env or files in the config directory. Therefore, as long as Laravel has these cache files, the .env or files in the config directory are not loaded.
Laravel starts creating cache files by executing this command.
2.php artisan cache:clear
Laravel deletes the cache files.
3.composer dump-autoload -o
Laravel loads the libraries in vendor directory automatically. It makes Laravel reload the classes (defined with namespace).
Result
My error message has gone!! Yay!!
Top comments (0)