Search code examples
phplaravelcachinglaravel-artisan

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


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

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?


Solution

  • 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.

    Expansion on points 1 and 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 @include directives 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/cache and storage directories.