Answer the question
In order to leave comments, you need to log in
How to hang session on redis in laravel?
Was guided by the official manual, but did not want to work. Google didn't help either.
1. Installed Redis (predis/predis). Works correctly with Laravel, facade is available.
2. Set up config/database.php:
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'predis'),
'prefix' => Str::slug(env('APP_NAME', 'laravel'), '_').'_database_',
],
'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),
],
/* Насколько понял должно быть достаточно default подключения,
но для теста, по нагугленным мануалам, сделал отдельное */
'session' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 1,
],
],
'driver' => env('SESSION_DRIVER', 'redis'),
'connection' => env('SESSION_CONNECTION', 'session'),
/* Вместо default здесь session. */
Answer the question
In order to leave comments, you need to log in
In the .env file in the line
Specify
Also make sure that you read .env
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question