3

i cloned a laravel project from bitbuket . also run all necessary command to get all vendors files like :

composer dump-autoload
composer install
php artisan cache:clear
php artisan clear-compiled

also deleted the file /public_html/bootstrap/cache/config.php

but i am getting the below error when i try to launch the project :

file_put_contents(C:\xampp\htdocs\laravelstart\storage\framework/sessions/sRPb1A6BKrshhH8HPAR2fXVEcCH4daYCLxgo4b8M): failed to open stream: No such file or directory

Paul Floyd
  • 5,530
  • 5
  • 29
  • 43
roche
  • 127
  • 1
  • 2
  • 15
  • Could you please explain about your error and put your coding sample – Googlian Jan 08 '19 at 11:11
  • you have tried already a possible solution, Please elaborate your question with more detail. – Udhav Sarvaiya Jan 08 '19 at 11:16
  • 1
    Possible duplicate of https://stackoverflow.com/questions/46959985/laravel-5-show-errorexception-file-put-contents-failed-to-open-stream-no-such-f Did you try clearing the cache and then clearing your local cache before re-loading the page? – Petay87 Jan 08 '19 at 11:19
  • Possible duplicate of [Laravel 5 show ErrorException file\_put\_contents failed to open stream: No such file or directory](https://stackoverflow.com/questions/46959985/laravel-5-show-errorexception-file-put-contents-failed-to-open-stream-no-such-f) – Petay87 Jan 08 '19 at 11:25
  • Hey, I know its been a long time. Can you please tell me how you were able to solve the problem? – Amit Sarwara Feb 05 '20 at 09:30
  • 1
    I noticed that the slashes face two different directions in the file path. Is that just a mistake in the logging? Or could that be part of why it's not working? – Danegraphics Jul 08 '21 at 15:25

9 Answers9

10

rm -rf bootstrap/cache/config.php (delete)

php artisan config:cache

Melih Sevim
  • 930
  • 6
  • 9
3

There can be various reasons why that error happened.

  1. Try to delete all cached files.
    rm -rf bootstrap/cache/config.php
    php artisan config:clear
    php artisan cache:clear
    php artisan config:cache

  2. If the above actions does not work, then try this again.
    Give permission to the directories in storage directory: app, framework, logs

    sudo chmod -R 777 storage/app
    sudo chmod -R 777 storage/framework
    sudo chmod -R 777 storage/logs

1

Try the command: php artisan config:cache it clear the configuration cache of your project. The problem may be that you cloned it, and the configuration is not prepared for your new server :)

nyu.exe
  • 317
  • 1
  • 9
0

If cleaning cache doesn't work (that might happen when you running under docker for instance) try just chmod 755 storage bootstrap/cache again. It worked for me

0

cd to your /storage/framework/cache/data or /storage/framework/sessions or any of the directories in the framework folder and type ls -la, you may see something like:

drwxr-sr-x  3 apache   apache   16 Oct 16 13:00 bd
drwxr-sr-x  3 apache   apache   16 Oct 16 17:38 be
drwxr-sr-x  3 root     apache   16 Oct 17 05:00 bf
drwxr-sr-x  3 apache   apache   16 Oct 16 13:07 c6
drwxr-sr-x  3 root     apache   16 Oct 16 16:15 d3
drwxr-sr-x  3 apache   apache   16 Oct 17 12:32 dd
drwxr-sr-x  3 apache   apache   16 Oct 17 12:32 e2
drwxr-sr-x  3 root     apache   16 Oct 16 16:00 e9
drwxr-sr-x  3 apache   apache   16 Oct 16 21:25 f6
drwxr-sr-x  3 apache   apache   16 Oct 16 16:56 f8
drwxr-sr-x  4 apache   apache   26 Oct 17 06:00 fa

As you can see some directories are owned by root, to fix this cd into the storage directory and run:

(first check which user:group you need, for AWS it could be ec2-user:apache):

sudo chmod 2775 . && sudo chown -R apache:apache . && sudo chmod -R og-r . && sudo find . -type d -exec chmod g=rwxs "{}" \; && sudo find . -type f -exec chmod g=rw  "{}" \; && sudo setfacl -d -m g::rwx . && sudo setfacl -d -m o::rx .

You may want to include this in your deployment script every time you push changes from your repo.

Max S.
  • 1,383
  • 14
  • 25
0

Go to directory laravel/bootstrap/cache and delete config.php file.

Bauroziq
  • 951
  • 9
  • 14
0

you can as well try this, it worked for me php artisan optimize:clear

Peter
  • 1,124
  • 14
  • 17
0

I had a similar problem, my problem was the name of the file was too long, you are naming your file like this: C:\xampp\htdocs\laravelstart\storage\framework/sessions/sRPb1A6BKrshhH8HPAR2fXVEcCH4daYCLxgo4b8M

I suggest: Try using a shorter name. Or Try to save the file in the root without path. Or check if you are using the right slashes in your path or use a shorter path, in my case i used this: file_put_contents('./storage/pdfs/file.jpg');

  • Try using a shorter file name? YESSS!!! That did it! Who knew windows carried these flaws over to their server environments! – Cmail Ultimate Aug 26 '21 at 20:59
0

I had a similar problem.

But I did realized that the sessions directory was missing.

Ensure that you have the sessions folder.

mkdir storage/framework/sessions/ - (linux)

Creating this directory fixed my issue.

Tarus
  • 126
  • 6