Dixon Chaudhary
Dixon Chaudhary

Reputation: 321

Issue faced during the Redis Configuration in Laravel

I have already installed predis in the Laravel with the help of the following command:

composer require predis/predis

I have also configured the database.php under config as:

'redis' => [

                'client' => 'predis',

                'clusters' => [
                        'default' => [
                                [
                                        'host' => env('REDIS_HOST', '10.21.7.28'),
                                        'password' => env('REDIS_PASSWORD', null),
                                        'port' => env('REDIS_PORT', 6379),
                                        'database' => 0,
                                        'read_write_timeout' => 60,
                                ],
                        ],
                ],

        ],

And I have also defined the session driver as redis in the session.php file as:

'driver' => env('SESSION_DRIVER', 'redis'),

Despite of doing all required configurations, I'm getting this error:

Redis connection [redis] not configured.

The detail of the error is:

/home/dixon/php7esupport/esupport/vendor/laravel/framework/src/Illuminate/Redis/RedisManager.php

 * @param  string|null  $name
 * @return \Illuminate\Redis\Connections\Connection
 *
 * @throws \InvalidArgumentException
 */

    public function resolve($name = null)
    {
        $name = $name ?: 'default';

        $options = $this->config['options'] ?? [];

        if (isset($this->config[$name])) {
            return $this->connector()->connect($this->config[$name], $options);
        }

        if (isset($this->config['clusters'][$name])) {
            return $this->resolveCluster($name);
        }

        throw new InvalidArgumentException("Redis connection [{$name}] not configured.");
    }

    /**
     * Resolve the given cluster connection by name.
     *
     * @param  string  $name
     * @return \Illuminate\Redis\Connections\Connection
     */
    protected function resolveCluster($name)
    {
        $clusterOptions = $this->config['clusters']['options'] ?? [];

        return $this->connector()->connectToCluster(
            $this->config['clusters'][$name], $clusterOptions, $this->config['options'] ?? []
        );
    }


    /**
     * Get the connector instance for the current driver.
     *
Arguments

    "Redis connection [redis] not configured."

I cannot figured out what exactly I'm missing. Can someone tell me which part I'm missing?

Upvotes: 0

Views: 1500

Answers (1)

Dixon Chaudhary
Dixon Chaudhary

Reputation: 321

I got the solution for this problem. I simply added the following part in config/session.php file as:

'driver' => env('SESSION_DRIVER', 'redis'),
'connection' => 'default',

Upvotes: 1

Related Questions