1 | <?php |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
2 | |||
3 | namespace Gewaer\Providers; |
||
4 | |||
5 | use Phalcon\Di\ServiceProviderInterface; |
||
6 | use Phalcon\DiInterface; |
||
7 | use Redis; |
||
8 | use function Gewaer\Core\envValue; |
||
9 | |||
10 | class RedisProvider implements ServiceProviderInterface |
||
11 | { |
||
12 | /** |
||
13 | * @param DiInterface $container |
||
14 | */ |
||
15 | 4 | public function register(DiInterface $container) |
|
16 | { |
||
17 | 4 | $config = $container->getShared('config'); |
|
18 | |||
19 | 4 | $container->setShared( |
|
20 | 4 | 'redis', |
|
21 | function () use ($config) { |
||
22 | //Connect to redis |
||
23 | 1 | $redis = new Redis(); |
|
24 | 1 | $redis->connect(envValue('REDIS_HOST', '127.0.0.1'), envValue('REDIS_PORT', '6379')); |
|
25 | 1 | $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); |
|
26 | 1 | return $redis; |
|
27 | 4 | } |
|
28 | ); |
||
29 | 4 | } |
|
30 | } |
||
31 |