执行命令:php artisan larabbs:calculate-active-user 时,报错:Class ‘Redis’ not found

1、执行命令:php artisan larabbs:calculate-active-user 时,报错:Class ‘Redis’ not found。如图1

执行命令:php artisan larabbs:calculate-active-user 时,报错:Class 'Redis' not found。

图1

PS E:/wwwroot/larabbs> php artisan larabbs:calculate-active-user
开始计算...

   Error

  Class 'Redis' not found

  at E:/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:75
     71▕      * @throws /LogicException
     72▕      */
     73▕     protected function createClient(array $config)
     74▕     {
  ➜  75▕         return tap(new Redis, function ($client) use ($config) {
     76▕             if ($client instanceof RedisFacade) {
     77▕                 throw new LogicException(
     78▕                     extension_loaded('redis')
     79▕                         ? 'Please remove or rename the Redis facade alias in your "app" configuration file in order to avoid collision with the PHP Redis extension.'

  • A class import is missing: You have a missing class import. Try importing this class: `Illuminate/Support/Facades/Redis`.

  1   E:/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:28
      Illuminate/Redis/Connectors/PhpRedisConnector::createClient()

  2   E:/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:32
      Illuminate/Redis/Connectors/PhpRedisConnector::Illuminate/Redis/Connectors/{closure}()

2、此命令中使用到了缓存,使用 Redis 作为缓存驱动。编辑 .dev 文件,添加:REDIS_CLIENT=predis

CACHE_DRIVER=redis
REDIS_CLIENT=predis

3、再次执行命令:php artisan larabbs:calculate-active-user ,不再报错。如图2

再次执行命令:php artisan larabbs:calculate-active-user ,不再报错。

图2

PS E:/wwwroot/larabbs> php artisan larabbs:calculate-active-user
开始计算...
成功生成!
PS E:/wwwroot/larabbs>

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/250698.html

(0)
上一篇 2022年5月1日
下一篇 2022年5月1日

相关推荐

发表回复

登录后才能评论