SncRedisBundle icon indicating copy to clipboard operation
SncRedisBundle copied to clipboard

predis cluster support environment variables

Open mSprunskas opened this issue 6 years ago • 5 comments

SncRedis config does not support env variables of "json" type, at least for dsn property. Example .env

REDIS_SENTINELS="[\"redis://redis-sentinel1.dev:26379\", \"redis://redis-sentinel2.dev:26379\", \"redis://redis-sentinel3.dev:26379\"]"

Example config

snc_redis:
    clients:
        default:
            type: predis
            alias: default
            dsn: '%env(json:REDIS_SENTINELS)%'

PHP warnings

PHP Warning:  strrpos() expects parameter 1 to be string, array given in /home/app/src/vendor/snc/redis-bundle/DependencyInjection/Configuration/RedisDsn.php on line 172
PHP Warning:  preg_match() expects parameter 2 to be string, array given in /home/app/src/vendor/snc/redis-bundle/DependencyInjection/Configuration/RedisDsn.php on line 185
PHP Warning:  preg_match() expects parameter 2 to be string, array given in /home/app/src/vendor/snc/redis-bundle/DependencyInjection/Configuration/RedisDsn.php on line 190
PHP Warning:  preg_match() expects parameter 2 to be string, array given in /home/app/src/vendor/snc/redis-bundle/DependencyInjection/Configuration/RedisDsn.php on line 203
PHP Warning:  strpos() expects parameter 1 to be string, array given in /home/app/src/vendor/snc/redis-bundle/DependencyInjection/Configuration/RedisDsn.php on line 212

JSON support would simplify SncRedis config as sentinel dsn count may differ in different enviroments.

mSprunskas avatar Dec 20 '18 11:12 mSprunskas

It should be noted that support for advanced environment variables was added in Symfony 3.4 and currently this bundle still supports 2.x.

curry684 avatar Dec 28 '18 13:12 curry684

Is there any chance this could be implemented soon? Currently I have to use multiple environment variables like this:

dsn:
    - 'redis://%env(REDIS_SERVER_1)%'
    - 'redis://%env(REDIS_SERVER_2)%'
    - 'redis://%env(REDIS_SERVER_3)%'

codegain avatar Dec 10 '19 09:12 codegain

@codegain Feel free to send a PR, I will be happy to review it.

B-Galati avatar Dec 10 '19 10:12 B-Galati

For phpredis at least, this is supported since https://github.com/snc/SncRedisBundle/pull/594

ostrolucky avatar Dec 17 '21 00:12 ostrolucky