Laravel: Class "Redis" Not Found Error - What To Do?

When you set up a new Laravel application to use Redis as a cache driver or broadcast driver, you may encounter the following error:


Why Does This Error Occur?

The reason for this error is usually either a missing Composer package or a missing Redis installation. In both cases, it appears once you try to use Redis in your system for the following:

  • Cache driver by setting CACHE_DRIVER=redis
  • Broadcast driver by setting BROADCAST_DRIVER=redis

Before going into the solutions, make sure you need Redis in your system. If you don't use it, you should change your drivers to something else.


Missing Composer Package

This is the most common reason to have this error. To fix it, run the following command:

composer require predis/predis

And once the package is installed, you should be able to use Redis as a cache or broadcast driver.


Missing Redis Installation

If you have installed the package, but the error is still there, you may need the Redis installation. To install Redis, follow the instructions on the official Redis website.

avatar

Just noted, if you do all of that above and still see the error.

Maybe, you have to add this too your Laravel .env configuration.

REDIS_CLIENT=predis

After that it will work.

👍 3

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 59 courses (1057 lessons, total 42 h 44 min)
  • 78 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord

Recent Premium Tutorials