尽管在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'),发布于 2021-04-05 04:14:01
接受的答案只是使用predis而不是PHPRedis的一个解决办法。如果您仍然想使用PHPRedis,并且仍然面临相同的问题作为主要问题,那么您可能遇到了与我相同的问题。在我的例子中,只有在通过crontab运行作业时,Please make sure the PHP Redis extension is installed and enabled错误才会抛出。在crontab中使用的PHP版本与我安装PHP的PHP版本不一样。我就是这样做的:
MacBook-Pro:hpt hantran$ which php
/usr/local/bin/php更改crontab
* * * * * cd /Applications/XAMPP/xamppfiles/htdocs/hpt && php artisan schedule:run >> /dev/null 2>&1* * * * * cd /Applications/XAMPP/xamppfiles/htdocs/hpt && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1发布于 2020-12-17 13:03:29
将此添加到env文件中
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_CLIENT=predis <---Add this line-->https://stackoverflow.com/questions/60364869
复制相似问题