Skip to content

Commit 5a83dff

Browse files
committed
minor #10548 Clarifying that .env can be used on production (weaverryan)
This PR was merged into the 4.1 branch. Discussion ---------- Clarifying that .env can be used on production Hi guys! This is a question that I got repeatedly at a conference recently, so I think we need to make it clear: there is no real disadvantage to using a `.env` file on production and people should choose whatever option is most natural for their environment. Cheers! Commits ------- bc5ad90 Clarifying that .env can be used on production
2 parents 90c2b62 + bc5ad90 commit 5a83dff

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

deployment.rst

+19-8
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,27 @@ B) Configure your Environment Variables
125125
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
126126

127127
Most Symfony applications read their configuration from environment variables.
128-
While developing locally, you'll usually store these in a ``.env`` file. But on
129-
production, instead of creating this file, you should set *real* environment variables.
128+
While developing locally, you'll usually store these in a ``.env`` file. On production,
129+
you have two options:
130130

131-
How you set environment variables, depends on your setup: they can be set at the
132-
command line, in your Nginx configuration, or via other methods provided by your
133-
hosting service.
131+
1. Create "real" environment variables. How you set environment variables, depends
132+
on your setup: they can be set at the command line, in your Nginx configuration,
133+
or via other methods provided by your hosting service.
134134

135-
At the very least you need to define the ``APP_ENV=prod`` environment variable
136-
to run the application in ``prod`` mode, but depending on your application you
137-
may need to define other env vars too.
135+
2. Or, create a ``.env`` file just like your local development (see note below)
136+
137+
There is no significant advantage to either of the two options: use whatever is
138+
most natural in your hosting environment.
139+
140+
.. note::
141+
142+
If you use the ``.env`` file on production, you may need to move your
143+
``symfony/dotenv`` dependency from ``require-dev`` to ``require`` in ``composer.json``:
144+
145+
.. code-block:: terminal
146+
147+
$ composer remove symfony/dotenv
148+
$ composer reuire symfony/dotenv
138149
139150
C) Install/Update your Vendors
140151
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)