From 379840c077455f4ee92b54e5d19e78e9853b3a74 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 17 Jul 2017 12:23:38 +0200 Subject: [PATCH 1/3] Added a note about container parameters and env vars --- components/dotenv.rst | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/components/dotenv.rst b/components/dotenv.rst index 6d7a4adffba..ceaefc98262 100644 --- a/components/dotenv.rst +++ b/components/dotenv.rst @@ -49,7 +49,7 @@ Load a ``.env`` file in your PHP application via ``Dotenv::load()``:: Given the following ``.env`` file content: -.. code-block:: bash +.. code-block:: shell # .env DB_USER=root @@ -76,11 +76,11 @@ shell scripts: .. code-block:: terminal - source .env + $ source .env Add comments by prefixing them with ``#``: -.. code-block:: bash +.. code-block:: shell # Database credentials DB_USER=root @@ -88,14 +88,25 @@ Add comments by prefixing them with ``#``: Use environment variables in values by prefixing variables with ``$``: -.. code-block:: bash +.. code-block:: shell DB_USER=root DB_PASS=${DB_USER}pass # Include the user as a password prefix +.. note:: + + When using the Dotenv component within the Symfony Framework, beware that + variables can't contain container parameters because they are not solved: + + .. code-block:: shell + + # '%kernel.project_dir%' is not resolved, so the value of this + # variable won't be the expected one and the application won't work + DB_URL=sqlite:///%kernel.project_dir%/test.db + Embed commands via ``$()`` (not supported on Windows): -.. code-block:: bash +.. code-block:: shell START_TIME=$(date) From f62709e2567725c7e44c192317d29379bf89a4f1 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 17 Jul 2017 12:35:37 +0200 Subject: [PATCH 2/3] Minor fix --- components/dotenv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/dotenv.rst b/components/dotenv.rst index ceaefc98262..dd170f504db 100644 --- a/components/dotenv.rst +++ b/components/dotenv.rst @@ -96,7 +96,7 @@ Use environment variables in values by prefixing variables with ``$``: .. note:: When using the Dotenv component within the Symfony Framework, beware that - variables can't contain container parameters because they are not solved: + variables can't contain container parameters because they are not resolved: .. code-block:: shell From baf5322e7d264ecb62f6cc240514ef77b6a0a4e8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 17 Jul 2017 12:41:26 +0200 Subject: [PATCH 3/3] Use the real env var name used by Symfony --- components/dotenv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/dotenv.rst b/components/dotenv.rst index dd170f504db..397962df817 100644 --- a/components/dotenv.rst +++ b/components/dotenv.rst @@ -102,7 +102,7 @@ Use environment variables in values by prefixing variables with ``$``: # '%kernel.project_dir%' is not resolved, so the value of this # variable won't be the expected one and the application won't work - DB_URL=sqlite:///%kernel.project_dir%/test.db + DATABASE_URL=sqlite:///%kernel.project_dir%/test.db Embed commands via ``$()`` (not supported on Windows):