获得“请确保已安装并启用 PHP Redis 扩展”。尽管加载了扩展程序,但错误

Ale*_*ere 4 redis laravel

Please make sure the PHP Redis extension is installed and enabled.尽管redis.so在 MacOS 上安装了扩展程序,但我的日志中仍然收到垃圾邮件。我通过运行安装了 Redis 扩展pecl install redis,成功并显示以下消息:

Installing '/usr/local/Cellar/php/7.3.12/pecl/20180731/redis.so'
install ok: channel://pecl.php.net/redis-5.1.1
Extension redis enabled in php.ini
Run Code Online (Sandbox Code Playgroud)

通过运行phpinfo()tinker,我可以看到我的加载php.ini就是

Configuration File (php.ini) Path => /usr/local/etc/php/7.3
Loaded Configuration File => /usr/local/etc/php/7.3/php.ini
Run Code Online (Sandbox Code Playgroud)

如果我打开/usr/local/etc/php/7.3/php.ini,extension="redis.so"会列在文件的顶部。

让这越来越奇怪的是,如果我深入研究原始Please make sure the PHP Redis extension is installed and enabled.错误的来源,它看起来是 in laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:76,如下所示:

throw new LogicException(extension_loaded('redis') ? 'Please remove or rename the Redis facade alias in your "app" configuration file in order to avoid collision with the PHP Redis extension.'  : 'Please make sure the PHP Redis extension is installed and enabled.');
Run Code Online (Sandbox Code Playgroud)

因此,根据此,加载扩展。但是,如果我tinker再次加载并运行,extension_loaded('redis')则会得到true结果。

我一生都无法弄清楚这里发生了什么。为什么PhpRedisConnector看不到扩展已加载?

为了完整起见,我还按照 Laravel 文档的指示Redis从我的app.php文件中删除了别名。

Fel*_*hes 7

对于那些使用 安装 Redis 的人composer require predis/predis,如 Laravel 官方文档中所述。

config/database.php,改变:

'redis' => [

    //'client' => env('REDIS_CLIENT', 'phpredis'),
    'client' => env('REDIS_CLIENT', 'predis'),
Run Code Online (Sandbox Code Playgroud)