17
votes

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.

4
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.sunny kashyap

4 Answers

30
votes

make sure to run this command:

sudo chmod 777 -R bootstrap/cache
15
votes

Just type:

cd bootstrap/
mkdir cache
cd .. 
composer install
8
votes

run this command

php artisan optimize --force

it will create services.php and compiled.php

0
votes

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