php - 存储文件夹问题 - 获取无效参数异常

标签 php laravel

在过去的几个小时里,我一直在尝试加载我的主页 View 。我在存储/框架目录中创建了以下文件夹

views
sessions
cache

我在 iTerm 中运行了以下命令

php artisan config:clear
php artisan cache:clear
composer dump-autoload
composer install

此外,我更新了 homestead 和 laravel 框架,但我仍然遇到同样的错误。有什么原因导致这不起作用吗?

这里是错误

(1/1) InvalidArgumentException Please provide a valid cache path.

编辑 2:这是我的 config/app.php 文件


return [

    /*
    |--------------------------------------------------------------------------
    | Default Cache Store
    |--------------------------------------------------------------------------
    |
    | This option controls the default cache connection that gets used while
    | using this caching library. This connection is used when another is
    | not explicitly specified when executing a given caching function.
    |
    | Supported: "apc", "array", "database", "file", "memcached", "redis"
    |
    */

    'default' => env('CACHE_DRIVER', 'file'),

    /*
    |--------------------------------------------------------------------------
    | Cache Stores
    |--------------------------------------------------------------------------
    |
    | Here you may define all of the cache "stores" for your application as
    | well as their drivers. You may even define multiple stores for the
    | same cache driver to group types of items stored in your caches.
    |
    */

    'stores' => [

        'apc' => [
            'driver' => 'apc',
        ],

        'array' => [
            'driver' => 'array',
        ],

        'database' => [
            'driver' => 'database',
            'table' => 'cache',
            'connection' => null,
        ],

        'file' => [
            'driver' => 'file',
            'path' => storage_path('framework/cache'),
        ],

        'memcached' => [
            'driver' => 'memcached',
            'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
            'sasl' => [
                env('MEMCACHED_USERNAME'),
                env('MEMCACHED_PASSWORD'),
            ],
            'options' => [
                // Memcached::OPT_CONNECT_TIMEOUT  => 2000,
            ],
            'servers' => [
                [
                    'host' => env('MEMCACHED_HOST', '127.0.0.1'),
                    'port' => env('MEMCACHED_PORT', 11211),
                    'weight' => 100,
                ],
            ],
        ],

        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Cache Key Prefix
    |--------------------------------------------------------------------------
    |
    | When utilizing a RAM based store such as APC or Memcached, there might
    | be other applications utilizing the same cache. So, we'll specify a
    | value to get prefixed to all our keys so we can avoid collisions.
    |
    */

    'prefix' => 'laravel',

];

和我的.env

APP_ENV=local
APP_KEY=base64:zVCAwUs7ONVbb/gWHhzDEkbBfmcNvqkCIU0tvcaGUQ4=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://bitpaigow.localhost:8000

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=paigow
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=

最佳答案

异常:

InvalidArgumentException Please provide a valid cache path.

不是在 Laravel Cache 中引发的,但它可以在 Illuminate\View\Compilers\Compiler 类中找到,准确地说是在该类的构造函数中:

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

因此错误是由 View Compiler 类引发的,它找不到已编译 View 缓存 的路径。鉴于您发布的代码,我的建议是:

  1. config/cache.php中恢复原来的stores.file.path配置:
'path' => storage_path('framework/cache/data'),
  1. 检查您的服务器在 storage/framework/views 目录中是否具有正确的权限:进入、读取和写入
  2. 检查你的 config/view.php 文件,它应该是这样的:
<?php

return [
    /*
    */
    'paths' => [
        resource_path('views'),
    ],
    /*
    */
    'compiled' => env(
        'VIEW_COMPILED_PATH',
        realpath(storage_path('framework/views'))
    ),
];
  1. 检查您的 .env 文件,您没有将 VIEW_COMPILED_PATH 条目设置为某个奇怪的路径。
  2. php artisan config:clear
  3. 最后但最不重要的一点:重新启动 HTTP 服务器

关于php - 存储文件夹问题 - 获取无效参数异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57576115/

相关文章:

php - 单个查询以获取过去 7 天的个人计数

php - 在 .append() 之后编辑 DIV

php - Laravel:无需协议(protocol)即可设置 Assets

php - Woocommerce API PHP 响应 header

PHP-mysql查询案例问题

php - Laravel 队列错误 'Illuminate\Http\UploadedFile' 的序列化是不允许的

php - Laravel 5.4 - 在集合中使用自定义属性模型

php - 委托(delegate) Laravel - 具有条件角色的 Eloquent 查询

php - 指定 Eloquent 模型上可以访问和查询哪些列

php - 如果列名与关键字 sql 匹配,则求和列