swarrot / SwarrotBundle

A symfony bundle for swarrot integration
MIT License
89 stars 59 forks source link

Problem with symfony/dotenv #131

Closed SZelenko closed 6 years ago

SZelenko commented 6 years ago

My .env

SWARROT_RABBIT_MQ_HOST=rabbitmq
SWARROT_RABBIT_MQ_PORT=15672
SWARROT_RABBIT_MQ_LOGIN=admin
SWARROT_RABBIT_MQ_PASSWORD=admin

And has configuration:

swarrot:
    connections:
        rabbitmq:
            host: %env(SWARROT_RABBIT_MQ_HOST)%
            port: %env(SWARROT_RABBIT_MQ_PORT)%
            login: %env(SWARROT_RABBIT_MQ_LOGIN)%
            password: %env(SWARROT_RABBIT_MQ_PASSWORD)%

On try clear cache i got: Invalid type for path "swarrot.connections.rabbitmq.port". Expected int, but got string.

As i know dotenv uses strings only (like bash etc..)

I think ->integerNode('port')->defaultValue(5672)->end() should be changed to scalar with normalization to int.

PS.: Used symfony/skeleton 3.4

alexvndre commented 6 years ago

Do you try with one host parameter?

.env

SWARROT_RABBIT_MQ_HOST=rabbitmq
SWARROT_RABBIT_MQ_PORT=15672
SWARROT_RABBIT_MQ_LOGIN=admin
SWARROT_RABBIT_MQ_PASSWORD=admin

swarrot.yaml

swarrot:
    connections:
        rabbitmq:
            host: %env(SWARROT_RABBIT_MQ_HOST)%:%env(SWARROT_RABBIT_MQ_PORT)%
            login: %env(SWARROT_RABBIT_MQ_LOGIN)%
            password: %env(SWARROT_RABBIT_MQ_PASSWORD)%

(Works for me with a mongo bundle)

Edit: not working :(

SZelenko commented 6 years ago

Sorry, haven't time to answer. Yes, it will not work because bundle uses separated params. Best solution, i think, is using dsn string.

odolbeau commented 6 years ago

Sorry for the late answer.

We're discussing dsn support on #124 which is definitively the best solution.

Did you try to cast your parameter to int like this? It may do the job until we agree on an implementation for dsn. :)

SZelenko commented 6 years ago

Did you try to cast your parameter to int like this? It may do the job until we agree on an implementation for dsn. :)

Oh thaks for it. I really misted this case!.. But dsn will be a good workaround :)