Code
use Illuminate\Support\Facades\Redis;
Redis::set($key, $data, 'EX', $expiry);
in app.php
$app->withFacades();
$app->withEloquent();
$app->register(Illuminate\Redis\RedisServiceProvider::class);
$app->configure('database');
Using the above code gives Class 'Redis' not found error. This error occurs only when the below packages are installed.
"illuminate/redis": "^6.5",
"illuminate/mail": "^6.5",
"laravel/lumen-framework": "^6.0",
With below packages which has lower versions it works without any error/issues.
"laravel/lumen-framework": "^5.8.*",
"illuminate/redis": "^5.8",
"illuminate/mail": "^5.8",
So why is it giving error when packages are upgraded.
If you are using Laravel 8
, in the database.php
file, replace the following line:
'client' => env('REDIS_CLIENT', 'phpredis')
to:
'client' => env('REDIS_CLIENT', 'predis')
then, add the predis
dependency with composer
:
composer require predis/predis
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With