Laravel file_put_contents error on shared hosting
Solution 1
What you should do is looking for occurrences of xampp
in your application because it seems you have sessions that are written to same folder that you have on your machine and obviously such directory doesn't exist on web server.
Especially make sure you in session.php
you have:
'files' => storage_path('framework/sessions'),
and remove config cache from bootstrap/cache
directory just in case
Solution 2
I had the same issue here.
I tried to run php artisan config:cache
but it didn't work out
Then I delete all my sessions in /myprojectname/storage/framework/
but still didn't work out on shared hosting but worked fine on localhost.
Here's what worked:
I delete the cache folder in /myprojectname/bootstrap/
and ran the application and got this error:
Exception thrown with message "The /hosthome/hostuser/myprojectname/bootstrap/cache directory must be present and writable."
I then made a new cache folder in /myprojectname/bootstrap/
and ran the site and it was up
in short terms
Navigate to your projects
/bootstrap/cache/
folder.Delete the contents of the directory and your good to go 😀
Related videos on Youtube
Comments
-
Martin Yakimov almost 2 years
I created my Laravel app and I am uploading on shared hosting. It's show error:
file_put_contents(D:\xampp\htdocs\Laravel\storage\framework/sessions/FlEPsHNW7Rggfb9wvDZ71K7D2YQNNQK0epRBRQnW): failed to open stream: No such file or directory
This is folder from my computer. I read same problems but I am on shared hosting and I don't have a composer or artisan for operations.
Thanks in advance!
-
teeyo over 6 yearswell there's no
D:\xampp\htdocs\Laravel\storage\framework/sessions/FlEPsHNW7Rggfb9wvDZ71K7D2YQNNQK0epRBRQnW
in your shared host if I'm guessing right !! I mean D:\xampp... noway -
teeyo over 6 yearsYou probably need to clear some cache or something, because there's still your local xampp configuration somewhere
-
Martin Yakimov over 6 yearsYes, this folder does not exist. It's from my computer.
-
Martin Yakimov over 6 yearsHow I clear cache? I don't have artisan
-
-
Martin Yakimov over 6 years'files' => storage_path('framework/sessions'), -> this is right. In bootstrap/cache hasn't cache
-
Marcin Nabiałek over 6 yearsAnd have you searched for all occurrences of
xampp
already? -
Martin Yakimov over 6 yearsYes, I searched.
-
Marcin Nabiałek over 6 yearsIt has to be somewhere. In case you are using very custom code you should search it also in database dump
-
Marcin Nabiałek over 6 yearsAs I said there is no way - there should be
xampp
somewhere. Webhosting haven't usedD:\xampp
from nowhere for sure so it has to be somewhere in files when you copied it or in database if you used custom configuration -
Martin Yakimov over 6 yearsOh yeah. I found this path in boostrap/cache/config.php. Now how I change?
-
Marcin Nabiałek over 6 yearsJust a moment before you don't have file in this directory :) Just remove this file - it's for performance reasons only. If you care about performance I would recommend you to use VPS not shared hosting
-
Martin Yakimov over 6 yearsI removed file, but will it harm the project?
-
Marcin Nabiałek over 6 yearsNo, it will only affect performance a bit. If you care as I said use VPS and run
php artisan config:cache
to cache it or you can run this from your code but this is completely other thing. -
Martin Yakimov over 6 yearsThanks for helping! I fixed it.
-
zonecc over 4 yearsThe files are created again once you run the website again.
-
Mitch M over 3 yearsThanks a bunch. I had renamed the existing ones to .old e.g config.php.old just to be safe . But it's worked well and the files were recreated the files when I reloaded the site url.