I kept getting this error when running any php artisan
commands.
[ErrorException]
file_put_contents(/Applications/MAMP/htdocs/code/bheng/md-bheng/bootstrap/cache/services.json): failed to open stream: No suc
h file or directory
How do I stop that ?
Edit - If the services.json
file does not exist, run php artisan serve
and then stop to forcibly create the file.
See: laravel services.json not created
Edit - updated answer to explain each command.
First, ignore the $
at the beginning of each command. These are to indicate that the commands are executed in Terminal.
To find your username, if you don't already know it, run:
$ whoami
For me, this would output rob
.
Next we want to change the ownership (chown
) of the services.json
file. We set the owner to your username (in my case rob
) and the group to _www
, which is the user MAMP runs as.
$ sudo chown rob:_www /Applications/MAMP/htdocs/code/bheng/md-bheng/bootstrap/cache/services.json
Next we want to change the ownership (chown
) of the storage
directory. We again set the owner to your username (in my case rob
) and the group to _www
. You may also notice the -R
option. This will execute this command recursively through all of the subdirectories contained within the storage
directory.
$ sudo chown -R rob:_www /Applications/MAMP/htdocs/code/bheng/md-bheng/storage
Finally, we want to change the permissions for individual files and directories within the storage directory. The following commands will find
within the storage
directory, all directories (-type d
) or all files (-type f
) and execute the command following -exec
.
$ sudo find /Applications/MAMP/htdocs/code/bheng/md-bheng/storage -type d -exec chmod 775 {} \;
$ sudo find /Applications/MAMP/htdocs/code/bheng/md-bheng/storage -type f -exec chmod 664 {} \;
The commands we're executing will change mode (chmod
) for each directory or file. Read this to learn more about permissions. I've linked to Wikipedia, because it's explains things quite simply. There are likely better resources out there.
Essentially however, 775
will grant read, write and execute permissions on the directories. 664
will grant read and write permissions on the files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With