Closed starit closed 8 years ago
Make sure $app->register(Illuminate\Redis\RedisServiceProvider::class);
is in bootstrap/app.php
.
For example:
I do have $app->register(Illuminate\Redis\RedisServiceProvider::class);
in my bootstrap/app.php
. when I open this issue
I spent haft day in solving this problem and finally success.
I need to add these config code in the bootstrap/app.php:
config(['database.redis'=> [ 'cluster' => env('REDIS_CLUSTER', false), 'default' => [ 'host' => env('REDIS_HOST', '127.0.0.1'), 'port' => env('REDIS_PORT', 6379), 'database' => env('REDIS_DATABASE', 0), 'password' => env('REDIS_PASSWORD', null), ], ]]);
and it works now
Looks like you didn't set up the redis.php config correctly.
@GrahamCampbell I wonder where the redis.php config in Lumen is? There is no configs folder in Lumen.
@starit You have to create the folder in the app and copy any configs you need to modify from the framework package into it.
thanks. @Garbee
@starit can you tell me how to do ? thank very much
@ooing copy files from vendor/laravel/lumen-framework/config/database.php and redis.php to your app/config, then replace the config value.
Also, config this code in bootstrap/app.php
$app->configure('database'); $app->configure('cache');
@amlun thanks
I wanted to use Redis for queues and needed to add $app->configure('database');
in bootstrap/app.php
to make it work (after added everything that the docs says).
The reason for this is that in RedisServiceProvider.php
, Lumen resolves the config for the database to pass to the RedisManager
class. If Lumen is not configured to work with a database, then the config will be NULL and it won't work.
https://github.com/laravel/lumen-framework/issues/414#issuecomment-219657373 <--- This should be added to the docs. There are no info about adding the redis
section to DB config.
Yup @viirre is right, $app->configure('database');
is missing in the docs.
Hi, this is my first time to use lumen, and version is 5.2 I want to connect to redis, and I have already installed these softwares in my Macbook
Then I got this problem.
FatalThrowableError in Database.php line 25: Type error: Argument 1 passed to Illuminate\Redis\Database::__construct() must be of the type array, null given, called in ./vendor/illuminate/redis/RedisServiceProvider.php on line 24
I've also installed predis by using composer, but it didn't work.
Also, I found that it seems like to be an invalid path in file ./vendor/illuminate/cache/RedisStore.php
use Illuminate\Redis\Database as Redis;
the Redis directory do not exists....What should I do ?