Description
Description
PR #38543 added support for runtime app environments, mentioning use cases such as loading an app with production configurations but with different sets of environment variables. However, the DotEnv
component uses APP_ENV
by default to locate and load various .env
files.
I propose it should use APP_RUNTIME_ENV
by default and fall back to APP_ENV
to locate and load .env
files. This would ensure consistent loading of environment variables, regardless of whether they are encrypted (secrets) or not.
At the moment, APP_RUNTIME_ENV
alone isn't sufficient. Consider a scenario where one wants to use Mailgun for production and Mailpit for staging environments (using the same Symfony configuration, i.e., APP_ENV=prod
for both). One would expect APP_RUNTIME_ENV=uat php bin/console secrets:decrypt-to-local --force
to work, but it won't, as .env.uat.local
will never be loaded. This is because APP_ENV
is set to prod
and DotEnv::bootEnv()
will only load .env.prod
and .env.prod.local
.
Example
-
Current behavior:
IfAPP_ENV=prod
andAPP_RUNTIME_ENV=uat
, it will load.env
,.env.prod
, and.env.prod.local
. -
Proposed behavior:
IfAPP_ENV=prod
andAPP_RUNTIME_ENV=uat
, it will load.env
,.env.uat
, and.env.uat.local
.