Ranx99's avatar

Error while setting up "phpredis" extension!

Steps I did to install the extension:

  1. run pecl install redis (Installation from pecl).
  2. add extension=redis.so to /etc/php/7.3/cli/php.ini.
  3. change redis's client to "phpredis" instead of "predis" in config/database.php.

And I am getting this error: Call to undefined method Illuminate\Support\Facades\Redis::connect()

0 likes
4 replies
manelgavalda's avatar

I don't quite understand you meant:

change redis's client to "phpredis" instead of "predis" in config/database.php.

Can you show us your database.php configuration file?

Ranx99's avatar

@MANELGAVALDA

As it says in the docs, I need to change the client

'redis' => [

    'client' => env('REDIS_CLIENT', 'phpredis'),

    'default' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', 6379),
        'database' => env('REDIS_DB', 0),
    ],

    'cache' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', 6379),
        'database' => env('REDIS_CACHE_DB', 1),
    ],

],
manelgavalda's avatar
Level 50

@RANX99 - Ah okay I understand. Looks like you added the extension to your php cli (command-line interface) version only, probably you are missing to add it in your server version.

I suggest you to use phpinfo() and take a look in your browser, and see if the phpredis extension is correctly installed in the server.

Ranx99's avatar

@MANELGAVALDA - That's right, I thought installing it via 'pecl' was enough..

I have add extension=redis.so to /etc/php/7.3/fpm/php.ini and now Its working..

thank you

1 like

Please or to participate in this conversation.