请提供有效的缓存路径

use*_*908 122 laravel laravel-5.2

我复制了一个工作的laravel应用程序并将其重命名为另一个应用程序.我删除了vendor文件夹并再次运行以下命令:

composer self-update

composer-update

npm install

bower install
Run Code Online (Sandbox Code Playgroud)

我正确配置了我的路线和一切但是现在当我尝试在浏览器中运行我的应用程序时,我收到以下错误:

Compiler.php第36行中的InvalidArgumentException:请提供有效的缓存路径.

Filesystem.php第111行中的ErrorException:file_put_contents(F:\ www\example\app\storage\framework/sessions/edf262ee7a2084a923bb967b938f54cb19f6b37d):无法打开流:没有此类文件或目录

我以前从来没有遇到过这个问题,我不知道是什么导致它我也不知道如何修复它,我已经在网上搜索解决方案,但到目前为止还没有找到.

Mau*_*ins 414

试试吧:

storage/framework下创建这些文件夹:

  • sessions
  • views
  • cache

现在它的工作!

  • mkdir -p storage/framework/{sessions,views,cache} (38认同)
  • 我结合这个与php artisan缓存:清除和php工匠配置:清除和PHP工匠视图:从下面的答案清楚,然后它工作 (15认同)
  • 您可以手动删除存储文件夹并通过cmd运行“php artisan storage:link”命令。然后按照上面的建议创建文件夹。更好的是,您可以保留以前的存储文件夹作为备份,然后复制 - 将框架文件夹粘贴到新的存储路径中。 (2认同)
  • git不会克隆空文件夹!我将为这3个文件夹创建一个folder.keeper文件。 (2认同)
  • 还要确保在缓存下添加“数据”文件夹,以防止出现以下错误“无法清除缓存。请确保您具有适当的权限” (2认同)

the*_*len 38

试试这个:

  1. php artisan cache:clear
  2. php artisan config:clear
  3. php artisan view:clear

  • 不适合我.我得到了`[InvalidArgumentException]请提供有效的缓存路径`.再次 (8认同)
  • 在运行此命令之前。在存储/框架下创建这些文件夹:**1) 会话 2) 视图 3) 缓存** (5认同)
  • 哈哈...运行这个命令也会给出同样的错误 (2认同)

use*_*966 26

确保存储目录中的以下文件夹:

  • 日志
  • 框架
  • 框架/缓存
  • 框架/缓存/数据
  • 框架/会议
  • 框架/测试
  • 框架/视图

下面是一个为你做的命令行片段

cd storage
mkdir logs
mkdir framework
mkdir framework/cache && framework/cache/data
mkdir framework/sessions
mkdir framework/testing
mkdir framework/views
chgrp -R www-data ../storage
chown -R www-data ../storage
Run Code Online (Sandbox Code Playgroud)


use*_*908 23

显然发生的事情是当我复制我的项目时,我的存储文件夹中的框架文件夹没有复制到新目录,这导致我的错误.

  • 还检查框架文件夹是否包含具有各自权限的所有子目录 (4认同)

Soh*_*med 20

您需要在“框架”内创建文件夹。请按照以下步骤操作:

cd storage/
mkdir -p framework/{sessions,views,cache}
Run Code Online (Sandbox Code Playgroud)

您还需要设置权限以允许 Laravel 在此目录中写入数据。

chmod -R 775 framework
chown -R www-data:www-data framework
Run Code Online (Sandbox Code Playgroud)


Whi*_*bit 19

我的2分钱

删除存储中的所有内容,然后执行以下操作:

> cd storage/
> mkdir -p framework/{sessions,views,cache}
> chmod -R 755 framework

// This last line depends on your user group settings so 
// it may not be applicable to you.
> chown -R www-data:www-data framework

Run Code Online (Sandbox Code Playgroud)

为我工作=)

  • 感谢您更新!通过这种方式了解 777 的不安全感比通过艰难的方式更好,对吗?:-) (2认同)

小智 16

您可以编辑readme.md,并在其他环境中安装laravel应用程序,如下所示:

## Create folders

```
#!terminal

cp .env.example .env && mkdir bootstrap/cache storage storage/framework && cd storage/framework && mkdir sessions views cache

```

## Folder permissions

```
#!terminal

sudo chown :www-data app storage bootstrap -R
sudo chmod 775 app storage bootstrap -R

```

## Install dependencies

```
#!terminal

composer install

```
Run Code Online (Sandbox Code Playgroud)


小智 13

可以从Illuminate\View\Compilers\Compiler.php中找到此错误的原因

public function __construct(Filesystem $files, $cachePath)
{
    if (! $cachePath) {
        throw new InvalidArgumentException('Please provide a valid cache path.');
    }

    $this->files = $files;
    $this->cachePath = $cachePath;
}
Run Code Online (Sandbox Code Playgroud)

BladeCompiler在Illuminate\View\ViewServiceProvider中调用构造函数

/**
 * Register the Blade engine implementation.
 *
 * @param  \Illuminate\View\Engines\EngineResolver  $resolver
 * @return void
 */
public function registerBladeEngine($resolver)
{
    // The Compiler engine requires an instance of the CompilerInterface, which in
    // this case will be the Blade compiler, so we'll first create the compiler
    // instance to pass into the engine so it can compile the views properly.
    $this->app->singleton('blade.compiler', function () {
        return new BladeCompiler(
            $this->app['files'], $this->app['config']['view.compiled']
        );
    });

    $resolver->register('blade', function () {
        return new CompilerEngine($this->app['blade.compiler']);
    });
}
Run Code Online (Sandbox Code Playgroud)

因此,进一步追溯,以下代码:

$this->app['config']['view.compiled']
Run Code Online (Sandbox Code Playgroud)

如果使用标准的laravel结构,通常位于/config/view.php中.

<?php
return [
    /*
    |--------------------------------------------------------------------------
    | View Storage Paths
    |--------------------------------------------------------------------------
    |
    | Most templating systems load templates from disk. Here you may specify
    | an array of paths that should be checked for your views. Of course
    | the usual Laravel view path has already been registered for you.
    |
    */
    'paths' => [
        resource_path('views'),
    ],
    /*
    |--------------------------------------------------------------------------
    | Compiled View Path
    |--------------------------------------------------------------------------
    |
    | This option determines where all the compiled Blade templates will be
    | stored for your application. Typically, this is within the storage
    | directory. However, as usual, you are free to change this value.
    |
    */
    'compiled' => realpath(storage_path('framework/views')),
];
Run Code Online (Sandbox Code Playgroud)

如果路径不存在,则realpath(...)返回false.因此,调用

'Please provide a valid cache path.' error.
Run Code Online (Sandbox Code Playgroud)

因此,要摆脱这个错误,你可以做的就是确保这一点

storage_path('framework/views')
Run Code Online (Sandbox Code Playgroud)

要么

/storage/framework/views
Run Code Online (Sandbox Code Playgroud)

存在:)

  • 谢谢你!这对我有用。我喜欢你完成每一步的方式。 (4认同)

Moh*_*nas 13

请尝试以下操作:

在存储/框架下创建这些文件夹:

  • 会议
  • 意见
  • 缓存/数据

如果仍然不起作用,请尝试

php artisan cache:clear
php artisan config:clear
php artisan view:clear
Run Code Online (Sandbox Code Playgroud)

如果出现无法清除缓存的错误。确保在缓存/数据中创建文件夹数据


Ran*_*dia 12

运行这些命令来创建所需的目录:

cd storage/
mkdir -p framework/{sessions,views,cache}
chmod -R 777 framework
Run Code Online (Sandbox Code Playgroud)

就是这样!

  • 根据所使用的组,使用“755”可能仍然更好。 (2认同)

Ndi*_*ong 12

  1. 首先清除缓存
php artisan cache:clear
php artisan config:clear
php artisan view:clear
Run Code Online (Sandbox Code Playgroud)
  1. 如果不起作用,请确保以下所有文件夹均可用
logs
framework
framework/cache 
framework/sessions 
framework/views
Run Code Online (Sandbox Code Playgroud)
  1. 如果所有建议均不起作用,请验证配置文件是否config/view.php存在。如果没有,您可以为您正在使用的 Laravel 获取此文件的副本,并将其复制到项目配置文件夹中。


小智 8

当我在存储文件夹及其子文件夹sessionviewscache 中创建框架文件夹时,我解决了这个问题。

转到您的 cmd 或终端,然后输入您的项目根路径,然后输入以下内容:

cd storage
mkdir framework
cd framework
mkdir sessions
mkdir views
mkdir cache
Run Code Online (Sandbox Code Playgroud)

再次转到您的项目根路径并运行composer update

在那之后,工匠完美地工作。


小智 8

检查以下文件夹是否存在,如果不存在则创建这些文件夹。

  • 存储/框架/缓存
  • 存储/框架/会话
  • 存储/框架/测试
  • 存储/框架/视图


小智 7

步骤1\xe3\x80\x81创建这些文件夹

\n
    \n
  • mkdir -p 存储/{应用程序、框架、日志}
  • \n
  • mkdir -p 存储/框架/{会话、视图、缓存}
  • \n
  • chmod -R 777 存储
  • \n
\n

步骤2\xe3\x80\x81清除缓存/配置/视图

\n
    \n
  • php artisan 缓存:清除
  • \n
  • php artisan 配置:清除
  • \n
  • php artisan 视图:清晰
  • \n
\n

  • 在任何情况下,都不要向系统上的所有用户授予完全写入权限,这就是您在此处使用“chmod -R 777”所做的事情。这是一个被黑客攻击的邀请,因为您的 Web 服务器进程用户现在也可以在那里写入。 (6认同)

小智 6

请在终端运行,

   sudo mkdir storage/framework
   sudo mkdir storage/framework/sessions
   sudo mkdir storage/framework/views
   sudo mkdir storage/framework/cache
   sudo mkdir storage/framework/cache/data
Run Code Online (Sandbox Code Playgroud)

现在您必须更改权限,

   sudo chmod -R 777 storage
Run Code Online (Sandbox Code Playgroud)


Ras*_*bal 5

步骤1php artisan storage:link

步骤 2:在存储文件夹中创建这些文件夹

确保存储目录中有以下文件夹:

logs
framework
framework/cache 
framework/sessions 
framework/views
Run Code Online (Sandbox Code Playgroud)

这对我有用