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.

Keith Yeoh
  • 731
  • 1
  • 7
  • 20
  • 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 Jul 05 '16 at 16:59

5 Answers5

32

make sure to run this command:

sudo chmod 777 -R bootstrap/cache
Paul Androschuk
  • 796
  • 7
  • 9
16

Just type:

cd bootstrap/
mkdir cache
cd .. 
composer install
grondon
  • 161
  • 1
  • 7
  • For security, the official recommendation is that composer never be run as root or sudo. Detailed reasoning is provided here: https://getcomposer.org/root – aaronfarr Jul 04 '17 at 14:47
10

run this command

php artisan optimize --force

it will create services.php and compiled.php

Ganesh Kandu
  • 601
  • 5
  • 15
0

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

fatemeh sadeghi
  • 1,757
  • 1
  • 11
  • 14
0

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

right click cache folder and checked

Folder is ready for archiving