@@ -40,6 +40,7 @@ class_exists(MissingDotenv::class, false) || class_exists(Dotenv::class) || clas
40
40
* - "prod_envs" to define the names of the production envs - defaults to ["prod"];
41
41
* - "test_envs" to define the names of the test envs - defaults to ["test"];
42
42
* - "use_putenv" to tell Dotenv to set env vars using putenv() (NOT RECOMMENDED.)
43
+ * - "dotenv_overload" to tell Dotenv to override existing vars
43
44
*
44
45
* When the "debug" / "env" options are not defined, they will fallback to the
45
46
* "APP_DEBUG" / "APP_ENV" environment variables, and to the "--env|-e" / "--no-debug"
@@ -84,6 +85,7 @@ class SymfonyRuntime extends GenericRuntime
84
85
* use_putenv?: ?bool,
85
86
* runtimes?: ?array,
86
87
* error_handler?: string|false,
88
+ * dotenv_overload?: ?bool,
87
89
* } $options
88
90
*/
89
91
public function __construct (array $ options = [])
@@ -96,10 +98,15 @@ public function __construct(array $options = [])
96
98
}
97
99
98
100
if (!($ options ['disable_dotenv ' ] ?? false ) && isset ($ options ['project_dir ' ]) && !class_exists (MissingDotenv::class, false )) {
99
- (new Dotenv ())
101
+ $ fullDotenvPath = $ options ['project_dir ' ].'/ ' .($ options ['dotenv_path ' ] ?? '.env ' );
102
+ ($ dotenv = new Dotenv ())
100
103
->setProdEnvs ((array ) ($ options ['prod_envs ' ] ?? ['prod ' ]))
101
104
->usePutenv ($ options ['use_putenv ' ] ?? false )
102
- ->bootEnv ($ options ['project_dir ' ].'/ ' .($ options ['dotenv_path ' ] ?? '.env ' ), 'dev ' , (array ) ($ options ['test_envs ' ] ?? ['test ' ]));
105
+ ->bootEnv ($ fullDotenvPath , 'dev ' , (array ) ($ options ['test_envs ' ] ?? ['test ' ]));
106
+ if ($ options ['dotenv_overload ' ] ?? false ) {
107
+ $ dotenv ->overload ($ fullDotenvPath );
108
+ }
109
+
103
110
$ options ['debug ' ] ?? $ options ['debug ' ] = '1 ' === $ _SERVER ['APP_DEBUG ' ];
104
111
$ options ['disable_dotenv ' ] = true ;
105
112
} else {
0 commit comments