file_put_contents(.../bootstrap/cache/services.json):打开流失败:没有这样的文件或目录 [英] file_put_contents(.../bootstrap/cache/services.json): failed to open stream: No such file or directory

查看:304
本文介绍了file_put_contents(.../bootstrap/cache/services.json):打开流失败:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行任何php artisan命令时,我一直收到此错误.

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):无法打开流:否suc
h文件或目录

[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

我该如何阻止?

推荐答案

编辑-如果services.json文件不存在,请运行php artisan serve,然后停止以强制创建该文件. 请参阅: laravel services.json未创建

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.

首先,忽略每个命令开头的$.这些是为了指示命令是在Terminal中执行的.

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

对我来说,这将输出rob.

接下来,我们要更改 services.json文件的自有属性(chown).我们将所有者设置为您的用户名(在我的情况下为rob),并将组设置为_www,这是MAMP运行的用户.

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

接下来,我们要更改 storage目录的拥有权限(chown).我们再次将所有者设置为您的用户名(在我的情况下为rob),并将组设置为_www.您可能还会注意到-R选项.这将通过storage目录中包含的所有子目录递归执行此命令.

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

最后,我们要更改存储目录中单个文件和目录的权限.以下命令将在storage目录,所有目录(-type d)或所有文件(-type f)中的find中执行-exec之后的命令.

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 {} \;

我们正在执行的命令将为每个目录或文件 ch 范围 mod e(chmod). 阅读此书以了解有关权限的更多信息.我已经链接到Wikipedia,因为它对事情的解释非常简单.那里可能会有更好的资源.

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.

实际上,775会授予对目录的读取,写入和执行权限. 664将授予对文件的读写权限.

Essentially however, 775 will grant read, write and execute permissions on the directories. 664 will grant read and write permissions on the files.

这篇关于file_put_contents(.../bootstrap/cache/services.json):打开流失败:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆