尽管在Please make sure the PHP Redis extension is installed and enabled.上安装了redis.so扩展,但我的日志中仍有大量的redis.so。我通过运行pecl install redis安装了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通过在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如果打开/usr/local/etc/php/7.3/php.ini,extension="redis.so"将列在文件的顶部。
让这变得越来越奇怪的是,如果我更深入地研究原始Please make sure the PHP Redis extension is installed and enabled.错误来自何处,它看起来就在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.');因此,根据这一点,扩展没有加载。但是,如果再次加载tinker并运行extension_loaded('redis'),则会得到true结果。
我不知道这到底是怎么回事。为什么PhpRedisConnector看不到加载扩展呢?
为了完整起见,我还按照Laravel的指示,从我的Redis文件中删除了app.php别名。
发布于 2020-05-16 22:28:48
对于那些用composer require predis/predis安装Redis的人,正如Laravel官方文档所描述的那样。
在config/database.php中,更改:
'redis' => [
//'client' => env('REDIS_CLIENT', 'phpredis'),
'client' => env('REDIS_CLIENT', 'predis'),https://stackoverflow.com/questions/60364869
复制相似问题