SwarrotBundle icon indicating copy to clipboard operation
SwarrotBundle copied to clipboard

Port cannot be configured by env var

Open pvgnd opened this issue 3 years ago • 2 comments

As the ENV var is resolved at runtime, port is casted into int by the bundle configuration class: https://github.com/swarrot/SwarrotBundle/blob/master/DependencyInjection/Configuration.php#L90

Configuration used:

swarrot:
    connections:
        event:
          host: '%env(APP_MESSAGE_BROKER_HOST)%'
          port: '%env(APP_MESSAGE_BROKER_PORT)%'
          login: '%env(APP_MESSAGE_BROKER_LOGIN)%'
          password: '%env(APP_MESSAGE_BROKER_PASSWORD)%'
bash-5.0$ php bin/console debug:config swarrot

Current configuration for extension with alias "swarrot"
========================================================

swarrot:
    connections:
        event:
            host: '%env(APP_MESSAGE_BROKER_HOST)%'
            port: 0
            login: '%env(APP_MESSAGE_BROKER_LOGIN)%'
            password: '%env(APP_MESSAGE_BROKER_PASSWORD)%'

pvgnd avatar Jan 20 '21 10:01 pvgnd

Hi @pvgnd and thanks or this bug report. I strongly advise you to use the FQDN instead:

swarrot:
    connections:
        rabbitmq:
            url: "amqp://%rabbitmq_login%:%rabbitmq_password%@%rabbitmq_host%:%rabbitmq_port%/%rabbitmq_vhost%"

It will be easier to configure the FQDN per environment and you won't have this cast problem anymore.

I thought we depreciated the connection as array configuration when we introduced the FQDN configuration but it's not the case. :/

odolbeau avatar Jan 21 '21 08:01 odolbeau

Good to know ! Thanks @odolbeau

pvgnd avatar Jan 21 '21 09:01 pvgnd