Do I have to introduce "dummy" environment variables in Symfony 5?

I am building a new application using Symfony 5 & AWS Elastic Beanstalk and would like to clarify the usage of environment variables. Do I have to explicitly introduce “dummy” environment variables in my .env file even though I use the ones I set for the server? The problem arises only when I try to use them in DBAL configuration.

Excerpt from my DBAL configuration:

dbal:
    dbname: '%env(RDS_DBNAME)%'
    host: '%env(RDS_HOSTNAME)%'
    port: 3306
    user: '%env(RDS_USER)%'
    password: '%env(RDS_PW)%'

I have set those variables in my server (EB config), also they are displayed in the phpinfo(); dump. However, during deployment’s cache clearing, Symfony throws an exception that “RDS_DBNAME” is not set. When I set it in the .env, then everything works correctly and it seems that the value is being overriden by server’s value.

This happens only for configuration. If I anywhere else try to access server’s variable that is not defined in the .env, but is set in the server configuration, everything also works without any exceptions.

Is this kind of behaviour expected? Thank you!

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *