Framework: Class 'Redis' not found

Created on 11 Sep 2019  ·  17Comments  ·  Source: laravel/framework

  • Laravel Version: 6.0.3
  • PHP Version: 7.3.9
  • Database Driver & Version:
php-redis 5.0.2-2
redis 5.0.5-1

Description:

I've starting to upgrade from 5.8 to Laravel 6.0. As recommended by the docs I've moved to phpredis.

I already removed the Redis alias, but it keeps using the wrong driver (at least I think so):
image

Steps To Reproduce:

  1. Upgrade to 6.0
  2. Removed predis
  3. Update all configs, including 'client' => env('REDIS_CLIENT', 'phpredis'),

If more info is needed, please let me know.

Most helpful comment

By default In Laravel 6 'client' => env('REDIS_CLIENT', 'phpredis'), is not working but when i change this 'client' => env('REDIS_CLIENT', 'predis'),.Why this Problem Occurred If It elaborate then it will be helpful

Change "phpredis" to "predis" it work pefectly!

All 17 comments

Sorry for the noise, it seems the php-redis extension wasn't (correctly) enabled.

Hmm, that suggested fix by the error handler is incorrect. It should suggest to install the extension, always, from Laravel 6 onwards.

//cc @freekmurze

We'll update the solution for this in ignition 👍

How to solve this?
Always fire when Change Redis Facade to RedisManager in app.php

@asterism612 Verify the redis extension is installed correctly and listed using phpinfo() (or any other CLI way).

@francoism90 I am facing same issue. Just installed php-redis and pecl install redis, but no success. Are you using Docker? Can you share your Dockerfile?

In my case, just noticed error is thrown randomly.

@robsontenorio Sorry, I'm not using Docker. Are you sure the extension has been enabled?

$ cat /etc/php/conf.d/redis.ini
extension=redis

Edit: I however agree with @mfn , also recommend using a package instead.

Just installed php-redis and pecl install redis

Btw, this reads confusing because it's meant to be the same thing. You probably meant sudo apt-get install php-redis and when you also do pecl… you _could_ end up with the same PHP extension twice on your system.

_Usually_ sudo apt-get install php-redis also enables it. If not, sudo phpenmod redis will do. It's implicitly does something similar to https://github.com/laravel/framework/issues/29955#issuecomment-549785611

Tread carefully as to not mix stuff here on your server!

By default In Laravel 6 'client' => env('REDIS_CLIENT', 'phpredis'), is not working but when i change this 'client' => env('REDIS_CLIENT', 'predis'),.Why this Problem Occurred If It elaborate then it will be helpful

This problem was related to a third party package. I am sorry.

By default In Laravel 6 'client' => env('REDIS_CLIENT', 'phpredis'), is not working but when i change this 'client' => env('REDIS_CLIENT', 'predis'),.Why this Problem Occurred If It elaborate then it will be helpful

Change "phpredis" to "predis" it work pefectly!

predis

This just saved me over 3 hours of work. Thank you @incepitkhoabui

'redis' => [
'cluster' => false,
'client' => env('REDIS_CLIENT', 'predis'),
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_DATABASE', 0),
'password' => env('REDIS_PASSWORD', ''),
],

],

'redis' => [
'cluster' => false,
'client' => env('REDIS_CLIENT', 'predis'),
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_DATABASE', 0),
'password' => env('REDIS_PASSWORD', ''),
],

],

In which file?

'redis' => [
'cluster' => false,
'client' => env('REDIS_CLIENT', 'predis'),
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_DATABASE', 0),
'password' => env('REDIS_PASSWORD', ''),
],

],

In which file?

It's in: /config/database.php

You can simply add
REDIS_CLIENT=predis to your .env file

By default In Laravel 6 'client' => env('REDIS_CLIENT', 'phpredis'), is not working but when i change this 'client' => env('REDIS_CLIENT', 'predis'),.Why this Problem Occurred If It elaborate then it will be helpful

Change "phpredis" to "predis" it work pefectly!

Thats a workaround and only good for dev-enviroment. You should use the pecl package instead of predis

install by sudo apt-get install php-redis

modify php.ini of your fpm-version.

restart php service

rename Redis to RedisManager in app.php aliases

check that predis is removed in vendor an composer.json

modify env file or set correct client in database.php

clear conf cache , composer dump-autoload

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gabriellimo picture gabriellimo  ·  3Comments

klimentLambevski picture klimentLambevski  ·  3Comments

felixsanz picture felixsanz  ·  3Comments

kerbylav picture kerbylav  ·  3Comments

iivanov2 picture iivanov2  ·  3Comments