【问题标题】:When I'm try to use redis on my project laravel 6.x it show this error message当我尝试在我的项目 laravel 6.x 上使用 redis 时,它会显示此错误消息
【发布时间】:2020-02-09 18:30:11
【问题描述】:

错误:

请删除或重命名“app”配置文件中的 Redis 外观别名,以避免与 PHP Redis 扩展冲突

我将此代码放在我的cache.php

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

还有我控制器中的那些代码:

$data['posts']   = cache('posts',function(){
      Post::with('user')
          ->select('title', 'created_at', 'user_id', 'thumbnail_path', 'content')
          ->orderBy('created_at','desc')
          ->take(50)
          ->get();
});

【问题讨论】:

    标签: php laravel redis laravel-6


    【解决方案1】:

    首先,您需要通过在终端中运行以下命令来确保您已经使用 composer 实际安装了 predis: composer require predis/predis

    然后你需要确保你的 .env 文件中有这个设置 REDIS_CLIENT=predis

    这在文档中有介绍: https://laravel.com/docs/6.x/redis

    【讨论】:

    • 你清除缓存了吗?试试 php artisan config:clear && php artisan config:cache && php artisan cache:clear
    【解决方案2】:

    当我在 cloudways.com 上托管我的 Laravel 应用程序时收到此错误消息。我通过从服务器“设置和包”页面安装 Redis 和 Supervisord 来修复它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-16
      • 2019-09-23
      • 1970-01-01
      • 1970-01-01
      • 2018-04-22
      • 2021-01-26
      • 2023-02-08
      • 1970-01-01
      相关资源
      最近更新 更多