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: components/dotenv.rst
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -58,8 +58,14 @@ Access the value with ``getenv()`` in your code::
58
58
$dbUser = getenv('DB_USER');
59
59
// you can also use ``$_ENV`` or ``$_SERVER``
60
60
61
+
The ``load()`` method never overwrites existing environment variables. Use the
62
+
``overload()`` method if you need to overwrite them::
63
+
64
+
// ...
65
+
$dotenv->overload(__DIR__.'/.env');
66
+
61
67
.. versionadded:: 4.2
62
-
Passing ``$overrideExistingVars`` as ``true`` in ``Dotenv::populate()`` or calling ``Dotenv::overload()`` instead of ``Dotenv::load()`` allow you to overwrite existing environment variables.
68
+
The ``Dotenv::overload()`` method was introduced in Symfony 4.2.
63
69
64
70
You should never store a ``.env`` file in your code repository as it might
65
71
contain sensitive information; create a ``.env.dist`` file with sensible
0 commit comments