17

After I ran composer update/ install then when I run php artisan cache:clear. I got the following error.

[ErrorException] file_put_contents({application-root-path}/bootstrap/cache/services.php): failed to open stream: No such file or directory

Is there any command able to re-cache the file? As for now no matter what php artisan function that I run also will caught into the same error.

p/s: Please comment below if you need me to provide any further information for debug use.

1
  • php artisan command run your application in CLI. When application run in CLI that time we can't use some server variable and many more. So that is causing that error. Please check your code and see where you use file_put_contents() function in application. Commented Jul 5, 2016 at 16:59

5 Answers 5

32

make sure to run this command:

sudo chmod 777 -R bootstrap/cache
Sign up to request clarification or add additional context in comments.

4 Comments

Alright, thanks ! If directory isn't found, create it by doing mkdir bootstrap/cache.
Don't set 777 on that folder, instead set the right group and only allow write access to that group. See this answer: stackoverflow.com/a/37266353/987864
Valid response for 5.4. I recently got caught on this after upgrading from 5.3.
sudo chmod -R 777 bootstrap/cache
16

Just type:

cd bootstrap/
mkdir cache
cd .. 
composer install

1 Comment

For security, the official recommendation is that composer never be run as root or sudo. Detailed reasoning is provided here: getcomposer.org/root
10

run this command

php artisan optimize --force

it will create services.php and compiled.php

1 Comment

As of Laravel 5.5, PHP artisan optimize is no longer required.
0

I solved this problem this way: If there is a cache directory, delete it and recreate it

Comments

0

Simple go to bootstrap folder and create new folder name cache :)

right click cache folder and checked

Folder is ready for archiving

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.