Lumen5.6 configuration redis
1. Installation redis expansion, the following two methods
1.1 .
composer require predis/predis
composer require illuminate/redis
1.2 (second written directly in composer.json)
"predis/predis": "^1.1", "illuminate/redis": "^5.6.39"
Delete composer.lock
执行sudo composer clearcache
然后sudo composer update
2. Introduction Redis support
In the directory bootstrap/app.php
you want to expand the introduction of redis
$app->register(Illuminate\Redis\RedisServiceProvider::class);
3. Enable Redis Helper
Lumen Laravel and some do not like the default 'Facades' and 'Eloquent' is not enabled, to imagine laravel redis used as the file should bootstrap / app.php in the 'Facades' and 'Eloquent' of $ app-> withFacades () and $ app-> withEloquent () opens like a comment
4. Redis server configuration parameters
The default system is called .env
in the redis configuration file, but generally after installation without these parameters, you can view the file path vendor/laravel/lumen-framework/config/database.php
in to see what parameters need to be configured, for example, my .env
file need to configure
IP = REDIS_HOST REDIS_PORT = 22188 REDIS_PASSWORD = Redis password
5. Use Redis
Test redis
$redis = Redis::connection(); var_dump($redis);