php - Expected int, but got string for redis portGet the solution ↓↓↓
I have this configuration for docker:
# docker-compose.yml environment: 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: ```yaml # pimcore.yml cache: pools: redis: enabled: true connection: 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.
People are also looking for solutions of the problem: attempt to read property "id" on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.