Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
Description
Description
The Runtime component currently supports a seamless integration with the Dotenv component, and even allow to control its behaviour via runtime options within theSymfonyRuntime
.
The current implementation accepts a single path, and uses it to boot the environment usingDotenv::bootEnv()
.
It would be great if we could extend this logic to support extra paths so applications could use multiple env vars files without having to handle the logic themselves.
The Dotenv component already support extra paths via the following functions:
public function load(string $path, string ...$extraPaths): void
public function overload(string $path, string ...$extraPaths): void
The idea here would be to add a newdotenv_extra_paths
runtime option so the runtime could use it, keeping in mind the existingdotenv_overload
option to call eitherload
oroverload
with those extra paths.
Our current use-case is to support region specific env vars files so we could have the following:
envs/dev.env
envs/dev-ap-southeast-2.env
Note that our use-case also incorporate custom path for the env vars files, but the extra paths solution discussed here would work independently.
Happy to work on a PR if the idea is acceptable
Example
$_SERVER['APP_RUNTIME_OPTIONS'] = ['dotenv_path' =>\sprintf('envs/%s.env',$_SERVER['APP_ENV'] ??'local'),'dotenv_extra_paths' => [\sprintf('envs/%s-%s.env',$_SERVER['APP_ENV'] ??'local',$_SERVER['AWS_REGION']), ],'dotenv_overload' =>true,];