laravel 如何让“php artisan cache: clear”命令起作用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52173500/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:01:47  来源:igfitidea点击:

How do I get the "php artisan cache: clear" command to work?

phplaravelcachingartisan

提问by Vd A

I'm using a Mac. Can not execute the command

我正在使用 Mac。无法执行命令

php artisan cache: clear

I get in return:

我得到回报:

Failed to clear cache. Make sure you have the proper permissions.

This is for Laravel. Any ideas how to fix this?

这是针对 Laravel 的。任何想法如何解决这一问题?

回答by shijinmon Pallikal

create storage/framework/cache/data directory manually.

手动创建存储/框架/缓存/数据目录。

回答by Strom

This could be one of several things(need more information to narrow it down):

这可能是几件事之一(需要更多信息来缩小范围):

  1. No cache files/records exist.(Updated to reflect your latest comments)
  2. If you are running a webserver (apache or ngix) as a different user, then you won't have permissions to the files as yourself.
  3. If you are using a cache driver other than file, like redis or database, make sure the credentials provided are correct.
  4. There could be a bug in the version of Laravel you are using; this would be unlikely.
  1. 不存在缓存文件/记录。(更新以反映您的最新评论)
  2. 如果您以不同的用户身份运行网络服务器(apache 或 ngix),那么您将无权访问这些文件。
  3. 如果您使用的是文件以外的缓存驱动程序,如 redis 或数据库,请确保提供的凭据正确无误。
  4. 您使用的 Laravel 版本可能存在错误;这不太可能。

Expansion on points 1 and 2:

第 1 点和第 2 点的扩展:

  1. This is normal behavior. If you have opened pages expecting them to be cached and they are not, split the page and utilize @includedirectives splitting out the dynamic and static elements of the page into separate blade files.

  2. I like to add my user to the same group as the web server's group(www). Then change the group for all of the files to www, with group read permissions, and write permissions only on the bootstrap/cacheand storagedirectories.

  1. 这是正常行为。如果您打开的页面希望它们被缓存而它们没有,请拆分页面并利用@include指令将页面的动态和静态元素拆分为单独的刀片文件。

  2. 我喜欢将我的用户添加到与 Web 服务器组 ( www)相同的组中。然后将所有文件的组更改为www,具有组读取权限,并且仅对bootstrap/cachestorage目录具有写入权限。

回答by George Hanson

I think it might possibly be a bug with the latest version of Laravel, however unlikely it may seem. I started a new project today and installed a fresh copy of Laravel 5.7 and it seems to cause the error above. However, if I use 5.6 then the error does not appear.

我认为这可能是 Laravel 最新版本的一个错误,不管它看起来不太可能。我今天开始了一个新项目并安装了 Laravel 5.7 的新副本,它似乎导致了上述错误。但是,如果我使用 5.6,则不会出现该错误。