Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Laravel says Class "Redis" not found when using phpredis

ErrorClass "Redis" not found

Short 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.

  • Applies to Laravel 12, PHP 8.3, phpredis, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 --ini
  2. 2Match what you see, then jump to its fix

    1. 1php -m prints nothing for redisThe phpredis extension is not installedFix
    2. 2pecl 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. 3Shared hosting or a locked image where PECL is not availableYou cannot install extensions on this hostFix

What does the error look like?

  • Class "Redis" not found
  • Class '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 redis

2Fix

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.so

3Verify

The module list now includes redis.

php -m | grep -i redis

Confirmed by github.com

Did this fix it?

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 redis

2Fix

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.so

3Verify

Run the check again for the PHP that serves the site, not only the terminal one.

php -m | grep -i redis

Confirmed by php.net

Did this fix it?

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/predis

2Fix

Require the package and tell Laravel to use it.

composer require predis/predis

# .env
REDIS_CLIENT=predis

3Verify

Clear the cached config and call Redis again.

php artisan config:clear

Confirmed by laravel.com

Did this fix it?

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:

Related fixes

Back 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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.