From 1d72bc25d53b0da77fe7556c492d93b32c497e76 Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Tue, 3 Jul 2018 19:55:43 +0200 Subject: [PATCH 1/2] Added key env processor to docs --- configuration/external_parameters.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/configuration/external_parameters.rst b/configuration/external_parameters.rst index bafbfd86662..5dfcbb4d50f 100644 --- a/configuration/external_parameters.rst +++ b/configuration/external_parameters.rst @@ -453,6 +453,18 @@ Symfony provides the following env var processors: 'auth' => '%env(file:AUTH_FILE)%', )); +``env(key:FOO:BAR)`` + Retrieves key ``FOO`` from array value ``BAR``: + + .. code-block:: yaml + + parameters: + env(APP_SECRETS): "{\"database_password\": \"secret\"}" + database_password: '%env(key:database_password:json:APP_SECRETS)%' + + .. versionadded:: 4.2 + The ``key`` processor was introduced in Symfony 4.2. + It is also possible to combine any number of processors: .. code-block:: yaml From 9c91cf1cf8e52ed2d260df7d8c1ae7d2b0ff3d31 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 4 Jul 2018 08:38:50 +0200 Subject: [PATCH 2/2] Reworded and added other config formats --- configuration/external_parameters.rst | 39 +++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/configuration/external_parameters.rst b/configuration/external_parameters.rst index 5dfcbb4d50f..bf17c3f2cf4 100644 --- a/configuration/external_parameters.rst +++ b/configuration/external_parameters.rst @@ -454,13 +454,42 @@ Symfony provides the following env var processors: )); ``env(key:FOO:BAR)`` - Retrieves key ``FOO`` from array value ``BAR``: + Retrieves the value associated with the key ``FOO`` from the array whose + contents are stored in the ``BAR`` env var: - .. code-block:: yaml + .. configuration-block:: - parameters: - env(APP_SECRETS): "{\"database_password\": \"secret\"}" - database_password: '%env(key:database_password:json:APP_SECRETS)%' + .. code-block:: yaml + + # config/services.yaml + parameters: + env(SECRETS_FILE): '/opt/application/.secrets.json' + database_password: '%env(key:database_password:json:file:SECRETS_FILE)%' + # if SECRETS_FILE contents are: {"database_password": "secret"} it returns "secret" + + .. code-block:: xml + + + + + + + /opt/application/.secrets.json + %env(key:database_password:json:file:SECRETS_FILE)% + + + + .. code-block:: php + + // config/services.php + $container->setParameter('env(SECRETS_FILE)', '/opt/application/.secrets.json'); + $container->setParameter('database_password', '%env(key:database_password:json:file:SECRETS_FILE)%'); .. versionadded:: 4.2 The ``key`` processor was introduced in Symfony 4.2.