请提供有效的缓存路径;laravel错误

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

composer self-update


composer-update


npm install


bower install

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

php第36行:请提供一个

.缓存路径

.输出说明

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

339460 次浏览

试试这个:

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

试试下面的方法:

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

  • sessions
  • views
  • cache

现在应该可以了

你可以用指令编辑你的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


```

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

/storage/framework/views

存在:)

我通过在index.php中添加这一行来解决这个问题:

$app['config']['view.compiled'] = "storage/framework/cache";

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

存在于框架目录中。

试试下面的方法:

在storage/framework下创建以下文件夹:

  • 会话
  • 的观点
  • 缓存/数据

如果还是不行,那就试试

php artisan cache:clear
php artisan config:clear
php artisan view:clear

如果得到一个不能清除缓存的错误。确保在cache/data中创建一个文件夹data

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

你需要在“框架”中创建文件夹。请遵循以下步骤:

cd storage/
mkdir -p framework/{sessions,views,cache}

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

chmod -R 775 framework
chown -R www-data:www-data framework

请在终端运行,

   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

现在你必须改变权限,

   sudo chmod -R 777 storage

我的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


为我工作过=)

当我在存储文件夹及其子文件夹会话的观点缓存中创建框架文件夹时,我解决了这个问题。

进入你的cmd或终端,然后输入你的项目根路径,然后输入以下命令:

cd storage
mkdir framework
cd framework
mkdir sessions
mkdir views
mkdir cache

再次回到项目根路径并运行作曲家更新

之后,工匠完美地工作。

错误:'请提供有效的缓存路径。的错误。

如果出现这些类型错误,则解决方案如下:-

请在存储/框架/缓存中创建数据文件夹

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

  • 存储/框架/缓存
  • 存储/框架/会话
  • 存储/框架/测试
  • 存储/框架/观点

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

  • 日志
  • 框架
  • 框架/缓存
  • 框架/缓存数据
  • 框架/会议
  • 框架/测试
  • 框架/观点

下面是一个命令行片段

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

__abc1: __abc0

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

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

logs
framework
framework/cache
framework/sessions
framework/views

这对我很有效

可能是存储文件夹没有应用程序和框架文件夹和必要的权限。在框架文件夹中,它包含缓存、会话、测试和视图。使用下面的命令,这将工作。

Use command line to go to your project root:
cd {your_project_root_directory}
Now copy past this command as it is:
cd storage && mkdir app && cd app && mkdir public && cd ../ && mkdir framework && cd framework && mkdir cache && mkdir sessions && mkdir testing && mkdir views && cd ../../ && sudo chmod -R 777 storage/

我希望这能解决你的问题。

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

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

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

如果这发生在服务器上:

sudo mkdir logs framework framework/cache framework/sessions framework/views
sudo chgrp -R www-data storage
sudo chmod -R ug+rwx storage

运行命令创建所需目录:

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

就是这样!

步骤1:PHP工匠存储:链接

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

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

< p >日志 框架 框架/缓存 框架/会议 框架/观点 它对我有用

这对我也有用

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

步骤1,创建这些文件夹

  • Mkdir -p storage/{app,framework,logs}
  • Mkdir -p storage/framework/{session,views,cache}
  • chmod -R 777 storage

步骤2,Clear cache/config/view

  • PHP工匠缓存:清除
  • PHP工匠配置:清除
  • PHP工匠视图:清除

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