Expected int, but got string for redis port

I have this configuration for docker:

# docker-compose.yml
      REDIS_SERVER: redis
      REDIS_PORT: 6379

And then in symfony I use this to configure parameters:

# parameters.yml

    redis_port: %env(REDIS_PORT)%

And then I use the parameter to configure Picmore's cache:

# pimcore.yml
                enabled: true
                    port: '%redis_port%'

But I get the error

Invalid type for path “pimcore.cache.pools.redis.connection.port”. Expected int, but got string.

The error is clear but I can’t solve it, I tried different options:

redis_port: '%env(REDIS_PORT)%'
redis_port: '%env(int:REDIS_PORT)%'

But I get the same error. How can I fix this?


You are using Symfony 3.3, but the int environment variable preprocessor was not added until Symfony 3.4, according to this.

I don’t think you’ll be able to use env vars to configure this value, since environment variables are strings by default.

Your options are to either use different parameters files for different environment, as things used to be done back then (which I understand can be inconvenient when using containers); or upgrade to a more recent version of Symfony.