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