Laravel says Class "Redis" not found when using phpredis
Class "Redis" not foundShort answer
Laravel uses the phpredis PHP extension by default, so a missing or disabled extension gives Class "Redis" not found. Check whether php -m lists redis for the same PHP that runs the app. Install and enable the extension, or set REDIS_CLIENT=predis and install the predis/predis package.
Fix it fast
1Find out which cause you have
Ask the same PHP binary that runs the app whether the redis extension is loaded, and see which ini files it reads.
php -m | grep -i redis php --ini2Match what you see, then jump to its fix
- 1
php -m prints nothing for redisThe phpredis extension is not installedFix - 2
pecl says redis is installed, yet php -m does not list it, or CLI works while the website failsThe extension is installed but not enabled for this PHPFix - 3
Shared hosting or a locked image where PECL is not availableYou cannot install extensions on this hostFix
- 1
What does the error look like?
Class "Redis" not foundClass 'Redis' not found
Cause 1 of 3
The phpredis extension is not installed
1Check
Laravel defaults to the phpredis client, which is a PHP extension and not a Composer package. Without it the Redis class does not exist.
php --ri redis2Fix
Install the extension with PECL (or your distribution's php-redis package where one exists), then enable it in php.ini.
pecl install redis
# then add this line to php.ini or a redis.ini in the conf.d directory:
extension=redis.so3Verify
The module list now includes redis.
php -m | grep -i redisConfirmed by github.com
Cause 2 of 3
The extension is installed but not enabled for this PHP
1Check
Installing the extension is not enough: it must also be enabled in the PHP configuration that the process reads. php --ini shows which files the command line uses, and the web server's PHP can read a different set.
php --ini
php --ri redis2Fix
Add the extension line to the ini that this PHP actually reads, then restart the process that serves requests (PHP-FPM, Apache or your queue worker).
extension=redis.so3Verify
Run the check again for the PHP that serves the site, not only the terminal one.
php -m | grep -i redisConfirmed by php.net
Cause 3 of 3
You cannot install extensions on this host
1Check
Laravel documents Predis as the alternative when the PhpRedis extension cannot be installed. It is written entirely in PHP.
composer show predis/predis2Fix
Require the package and tell Laravel to use it.
composer require predis/predis
# .env
REDIS_CLIENT=predis3Verify
Clear the cached config and call Redis again.
php artisan config:clearConfirmed by laravel.com
How do I stop it coming back?
- Install phpredis in the base image or provisioning script, not by hand on one server.
- Run php -m | grep redis in a deploy check for every PHP environment (CLI, FPM, workers).
- Keep REDIS_CLIENT in .env explicit so the client is a decision, not a default.
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:
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
- EZ EstimaterConstruction quoting and job tracking for contractors, on a Laravel and Firebase stack.
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
Related fixes
Back 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
Why a Filament panel feels slow on a Laravel server
The panel is fast on a small demo and slow once there are many resources, pages and widgets
A slow Filament panel on a server is most often running without the production caches.
3 causes, each with a fixBack end
Intervention Image will not save the file in a Laravel app
Can't write image data to path (/var/www/app/public/uploads/photo.jpg)
Intervention Image writes straight to a file path.
3 causes, each with a fixBack end
Laravel file upload returns 413 behind nginx
413 Content Too Large
A 413 means a limit refused the request body before Laravel could use it.
3 causes, each with a fixBack end
Laravel says the bootstrap/cache directory must be present and writable
The /var/www/app/bootstrap/cache directory must be present and writable.
Laravel writes its package manifest into bootstrap/cache and throws when that folder is missing or the current user cannot write to it.
2 causes, each with a fixBack end
Carbon::now() and now() return the wrong hour in Laravel
created_at values do not match the local time
Carbon::now() uses the PHP default timezone, and Laravel sets that from app.timezone in config/app.php on every boot.
3 causes, each with a fix