Wednesday, November 4, 2020

Laravel ErrorException file_put_contents

After working on any Laravel project for a period of time, its possible that you would change the project folder to another location or drive. Lets say I have a Laravel project called employeeManagement in C:\users\tboxmy\employeeManagement and I make a copy of this to Z:\tboxmy\workspace\project while renaming the project name. 


 

Problem

For some strange reason, the pages are not loading properly and the following error appears.

ErrorException

file_put_contents(Z:\tboxmy\workspace\project\storage\framework/sessions/c34niIDr5qyV8Fyf0qXFLXSF1IlOv3yOulSC9sHI): failed to open stream: No such file or directory 

I have also noticed that the same problem causing that ErrorException SOMETIMES doesn't appear but it is actually loading pages from the original folder location. So when I edit my codes in Z:\tboxmy\workspace\project the changes just doesn't appear in the application. To determine this, just try to rename the original project folder and this error WILL appear.

There are 2 aproches to solve this, which does the same thing.

Solution 1

Step 1

Open a command line and ensure you are in the same folder as the project, in this case Z:\tboxmy\workspace\project\
 

Step 2

Type the command 

php artisan config:cache 
 
 

Step 3 : Update the cache in all installed plugins/libraries

composer install
npm install
npm run dev

Solution 2

Step 1

Using a file manager, or at the command prompt, open the project folder and go to the folder bootstrap\cache
In this case Z:\tboxmy\workspace\project\bootstrap\cache
 

Step 2

Delete the file config.php

Repeat Step 3 above.

No comments:

Blog Archive