Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

HOVO's avatar
Level 1

Class 'Redis' not found

I want to build chat but when i start using redis it throw me that error.I have installed Redis on my project my .env

BROADCAST_DRIVER=redis

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

route for test if work

Route::get('/fire', function () {
    event(new \App\Events\NewMessageAdded());
    return 'ok';
});

What i am doing wrong ????

0 likes
17 replies
Andy_'s avatar

I have installed php-redis but am still getting the 'Class 'Redis' not found' error when trying to run any 'php artisan' command.

There is also a 'RedisException Connection refused' error when attempting to load the site itself.

This is the first time I've tried to get Redis properly up and running with Laravel, and it could well be a config issue, but the docs are fairly sparse....

UsmanBasharmal's avatar
Level 3

Which version of laravel are you using ?

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
81 likes
HOVO's avatar
Level 1

your suggestion help me now work it thank u very much :D

pSouper's avatar

I'm using laravel 8 sail/docker and getting this error too. The L8/Sail docs say that my container should already include redis: Before using Redis with Laravel, we encourage you to install and use the phpredis PHP extension via PECL. The extension is more complex to install compared to "user-land" PHP packages but may yield better performance for applications that make heavy use of Redis. If you are using Laravel Sail, this extension is already installed in your application's Docker container.

My phpinfo says I have redis and yet I still get this error thorwn when I set my .env var to redisCACHE_DRIVER=redis

Redis Support	enabled
Redis Version 	5.3.4
Redis Sentinel Version 	0.1
Available serializers 	php, json, igbinary 

have I missed something?

juliofagundes's avatar

@pSouper

The Redis Facade Alias

Laravel's config/app.php configuration file contains an aliases array which defines all of the class aliases that will be registered by the framework. For convenience, an alias entry is included for each facade offered by Laravel; however, the Redis alias is disabled because it conflicts with the Redis class name provided by the phpredis extension. If you are using the Predis client and would like to enable this alias, you may un-comment the alias in your application's config/app.php configuration file.

1 like
Yamen's avatar

Make sure to install redis pecl install redis , if you're using php >=7.3 pickle install redis It's unlikely to just change the REDIS_CLIENT to predis because Laravel docs itself encourages you to use phpredis

https://laravel.com/docs/9.x/redis#introduction

1 like
srdjan_marjanovic's avatar

@Yamen I'm struggling with installing redis with pickle (under php7.4 on ubuntu 22.04) as suggested: sudo pickle install redis I go through the process, everything finishes without errors (even checked the exit code of the command it's 0) but when I try to execute anything i get the Uncaught Error: Class 'Redis' not found

claudiorigo's avatar

Simplemente dejalo en CACHE_DRIVER=null en vez de CACHE_DRIVER=redis y en app>config dejalo desabilitado 'aliases' => [//'Redis' => Illuminate\Support\Facades\Redis::class,]

BROADCAST_DRIVER=log CACHE_DRIVER=file CACHE_DRIVER=array CACHE_DRIVER=database CACHE_DRIVER=null

Please or to participate in this conversation.