Skip to content

Document the DotEnv::overload() method #9568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions components/dotenv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ Access the value with ``getenv()`` in your code::
$dbUser = getenv('DB_USER');
// you can also use ``$_ENV`` or ``$_SERVER``

.. note::
The ``load()`` method never overwrites existing environment variables. Use the
``overload()`` method if you need to overwrite them::

// ...
$dotenv->overload(__DIR__.'/.env');

Symfony Dotenv never overwrites existing environment variables.
.. versionadded:: 4.2
The ``Dotenv::overload()`` method was introduced in Symfony 4.2.

You should never store a ``.env`` file in your code repository as it might
contain sensitive information; create a ``.env.dist`` file with sensible
Expand Down