首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >“请提供有效的缓存路径”错误在laravel中

“请提供有效的缓存路径”错误在laravel中
EN

Stack Overflow用户
提问于 2016-07-20 14:18:49
回答 23查看 338.6K关注 0票数 270

我复制了一个可工作的laravel应用程序,并将它重命名为另一个应用程序。我删除了供应商文件夹并再次运行以下命令:

代码语言:javascript
运行
复制
composer self-update

composer-update

npm install

bower install

但是,当我尝试在浏览器中运行我的应用程序时,我得到以下错误:

InvalidArgumentException在Compiler.php第36行:请提供一个有效的缓存路径。 file_put_contents(F:\www\example\app\storage\framework/sessions/edf262ee7a2084a923bb967b938f54cb19f6b37d):第111行中的ErrorException :ErrorException未能打开流:没有这样的文件或目录

我从来没有过这个问题,我不知道是什么原因,我也不知道如何解决它,我在网上搜索了一个解决方案,但到目前为止还没有找到。

EN

回答 23

Stack Overflow用户

发布于 2016-08-27 08:51:47

尝试以下几点:

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

  • sessions
  • views
  • cache

现在它应该起作用了

票数 799
EN

Stack Overflow用户

发布于 2016-07-20 14:42:12

试试这个:

  1. php artisan cache:clear
  2. php artisan config:clear
  3. php artisan view:clear
票数 58
EN

Stack Overflow用户

发布于 2018-05-02 11:46:15

此错误的原因可从Illuminate\View\Compilers\Compiler.php中跟踪。

代码语言:javascript
运行
复制
public function __construct(Filesystem $files, $cachePath)
{
    if (! $cachePath) {
        throw new InvalidArgumentException('Please provide a valid cache path.');
    }

    $this->files = $files;
    $this->cachePath = $cachePath;
}

构造函数由BladeCompiler在照明\View\ViewServiceProvider中调用

代码语言:javascript
运行
复制
/**
 * 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']);
    });
}

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

代码语言:javascript
运行
复制
$this->app['config']['view.compiled']

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

代码语言:javascript
运行
复制
<?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')),
];

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

代码语言:javascript
运行
复制
'Please provide a valid cache path.' error.

因此,要消除这个错误,您可以做的是确保

代码语言:javascript
运行
复制
storage_path('framework/views')

代码语言:javascript
运行
复制
/storage/framework/views

存在:)

票数 42
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38483837

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档