Header Ads

How to Fix the "Class 'Redis' Not Found" Error on Windows for Laravel


If you’re developing a Laravel application on Windows and encounter the error Class "Redis" not found, it means that Laravel is trying to use the Redis PHP extension, but it’s not installed or enabled on your system. Here’s a step-by-step guide to resolving this issue on a Windows environment.

Step 1: Download and Install the Redis PHP Extension

  1. Download the Redis Extension DLL:

    • Visit the PECL Redis page to find the version of Redis that matches your PHP version.
    • Download the appropriate php_redis.dll file for your PHP version from the PECL website.
  2. Place the DLL File:

    • Move the downloaded php_redis.dll file to your PHP extension directory. This is typically located at C:\php\ext on Windows.

Step 2: Enable the Extension in php.ini

  1. Open the php.ini File:

    • Navigate to your PHP installation directory, usually C:\php, and open the php.ini file with a text editor.
  2. Add the Redis Extension:

    • Add the following line to enable the Redis extension:
      ini
      extension=redis
    • Save and close the php.ini file.

Step 3: Restart Your Web Server

  • For Apache Users:

    • Open Command Prompt or PowerShell and restart Apache with the following command:
      bash
      httpd -k restart
  • For Other Web Servers:

    • Restart the web server according to its specific method.

Step 4: Verify the Installation

  1. Using PHP CLI:

    • Open Command Prompt and run:
      bash
      php -m | findstr redis
    • If redis appears in the output, the extension has been successfully installed.
  2. Using Laravel:

    • Check your Laravel application to ensure that Redis is now recognized and functioning properly.

Troubleshooting Tips

  • Ensure Compatibility: Double-check that the php_redis.dll file you downloaded matches your PHP version and architecture (x86 or x64).
  • Check PHP Configuration: Ensure that the php.ini file you edited is the one being used by your PHP installation.

By following these steps, you should be able to resolve the Class "Redis" not found error and get Redis up and running with your Laravel application on Windows.

No comments:

Powered by Blogger.