我已经使用以下命令在Laravel中安装了predis:
composer require predis/predis
我还在config下配置了database.php:
'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,
],
],
],
],
我还在session.php文件中将会话驱动程序定义为redis:
'driver' => env('SESSION_DRIVER', 'redis'),
尽管已完成所有必需的配置,但我收到此错误:
Redis connection [redis] not configured.
错误的详细信息是:
/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."
我无法弄清楚我到底错过了什么。有人能告诉我我错过了哪一部分吗?
答案 0 :(得分:0)
我得到了解决这个问题的方法。我只是添加了以下部分 config / session.php文件为:
'driver' => env('SESSION_DRIVER', 'redis'),
'connection' => 'default',