Laravel says the Predis client class cannot be found
Class "Predis\Client" not foundShort answer
Laravel is set to use Predis, but the predis/predis package is not in vendor/. Run composer require predis/predis, or composer install on the server if the package is already in composer.lock. If you would rather use the PhpRedis extension, set REDIS_CLIENT=phpredis and install the extension.
Fix it fast
1Find out which cause you have
Check whether Composer knows about the package and which client the app is told to use.
composer show predis/predis php artisan tinker --execute="echo config('database.redis.client');"2Match what you see, then jump to its fix
- 1
composer show says the package is not found.predis/predis was never requiredFix - 2
composer show predis/predis works on your laptop, but the error appears only on the server or in a container.The package is in composer.lock but the server's vendor folder is oldFix - 3
The app was working with PhpRedis, or the config says predis while you only installed the extension.REDIS_CLIENT points at a client you did not installFix
- 1
What does the error look like?
Class "Predis\Client" not found
Cause 1 of 3
predis/predis was never required
1Check
Laravel defaults to the PhpRedis extension. Predis is the package you add when the extension cannot be installed.
composer show predis/predis2Fix
Require the package, which also writes it to composer.json and composer.lock.
composer require predis/predis3Verify
The class now loads.
php artisan tinker --execute="echo get_class(new Predis\Client());"Confirmed by laravel.com
Cause 2 of 3
The package is in composer.lock but the server's vendor folder is old
1Check
A deploy that copies code without running Composer leaves vendor/ out of date. Composer installs the exact versions from composer.lock when you run install.
ls vendor/predis2Fix
Run Composer on the target machine as part of the deploy.
composer install --no-dev3Verify
The folder exists and the app boots.
ls vendor/predis
php -r "require 'vendor/autoload.php'; echo class_exists('Predis\\Client') ? 'ok' : 'missing';"Confirmed by getcomposer.org
Cause 3 of 3
REDIS_CLIENT points at a client you did not install
1Check
Laravel reads the client from the redis.client config value, which comes from REDIS_CLIENT and defaults to phpredis. After config:cache, a changed .env is ignored.
grep REDIS_CLIENT .env2Fix
Set the variable to the client you have, then clear the cached config.
# .env
REDIS_CLIENT=predis
php artisan config:clear3Verify
A Redis call from tinker works.
php artisan tinker --execute="Illuminate\Support\Facades\Redis::set('ping', 'pong'); echo Illuminate\Support\Facades\Redis::get('ping');"Confirmed by laravel.com
How do I stop it coming back?
- Commit composer.lock and run composer install in every deploy.
- Pick one Redis client per environment and put REDIS_CLIENT in the environment file explicitly.
- Run php artisan config:cache only after the .env is final.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Laravel says Class "Redis" not found when using phpredis
Class 'Redis' not found
Laravel uses the phpredis PHP extension by default, so a missing or disabled extension gives Class "Redis" not found.
3 causes, each with a fixBack end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fix