You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Symfony/Component/Dotenv/Dotenv.php
+24-2Lines changed: 24 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,21 @@ final class Dotenv
35
35
private$data;
36
36
private$end;
37
37
private$values;
38
+
private$usePutenv = true;
39
+
40
+
/**
41
+
* @var bool If we should use `putenv()` to define environment variables
42
+
* or not. Since Symfony 5.0 the default value is false
43
+
* because `putenv()` is not thread safe.
44
+
*/
45
+
publicfunction__construct(bool$usePutenv = true)
46
+
{
47
+
if (0 === \func_num_args()) {
48
+
@trigger_error(sprintf('The default value of "$usePutenv" argument of "%s\'s constructor will change from "true" to "false" in Symfony 5.0, you should define its value explicitly.', __METHOD__), E_USER_DEPRECATED);
49
+
}
50
+
51
+
$this->usePutenv = $usePutenv;
52
+
}
38
53
39
54
/**
40
55
* Loads one or several .env files.
@@ -126,7 +141,10 @@ public function populate(array $values, bool $overrideExistingVars = false): voi
126
141
continue;
127
142
}
128
143
129
-
putenv("$name=$value");
144
+
if ($this->usePutenv) {
145
+
putenv("$name=$value");
146
+
}
147
+
130
148
$_ENV[$name] = $value;
131
149
if ($notHttpName) {
132
150
$_SERVER[$name] = $value;
@@ -140,7 +158,11 @@ public function populate(array $values, bool $overrideExistingVars = false): voi
* @expectedDeprecation The default value of "$usePutenv" argument of "%s's constructor will change from "true" to "false" in Symfony 5.0, you should define its value explicitly.
0 commit comments