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

composer self-update

composer-update

npm install

bower install

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

php第36行:请提供一个 有效的缓存路径。 php第111行出现错误: 写入(F: \ www \ \ app \ \存储框架/会议/ edf262ee7a2084a923bb967b938f54cb19f6b37d): failed to open stream:没有这样的文件或目录

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


当前回答

我这边的问题(在localhost上部署时):有视图文件夹丢失.. 所以 如果你没有框架文件夹,你需要添加文件夹。 但如果已经存在框架文件夹,则确保所有以上文件夹,即 1. 缓存 2. 会话 3.的观点

存在于框架目录中。

其他回答

这个错误的原因可以从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;
}

该构造函数由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']);
    });
}

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

$this->app['config']['view.compiled']

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

<?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。因此,调用

'Please provide a valid cache path.' error.

因此,要摆脱这个错误,你能做的就是确保

storage_path('framework/views')

or

/storage/framework/views

存在:)

我在生产服务器上复制一个项目后也遇到过类似的情况。Apache通过符号链接访问了公用文件夹。

对于Apache或PHP服务,到项目的路径没有改变,因此它们使用缓存的文件路径指向旧的项目存储库。

重新启动Apache和PHP服务解决了这个问题。

在我的情况下,配置缓存文件都在boostrap/cache中丢失…所以我的解决方案是PHP手工配置:在boostrap/cache中重新创建缓存文件。

您的存储目录或其中一个子目录可能丢失。存储目录必须包含Laravel安装附带的所有子目录。

您可以编辑自述文件。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

```