10000 minor #10009 Added key env processor to docs (bobvandevijver, javiere… · symfony/symfony-docs@e22943b · GitHub
[go: up one dir, main page]

Skip to content

Commit e22943b

Browse files
committed
minor #10009 Added key env processor to docs (bobvandevijver, javiereguiluz)
This PR was merged into the master branch. Discussion ---------- Added key env processor to docs Not much more to say, this is documenting the feature added in symfony/symfony#27157. Fixes #9734. Commits ------- 9c91cf1 Reworded and added other config formats 1d72bc2 Added key env processor to docs
2 parents 254a72e + 9c91cf1 commit e22943b

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

configuration/external_parameters.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,47 @@ Symfony provides the following env var processors:
453453
'auth' => '%env(file:AUTH_FILE)%',
454454
));
455455
456+
``env(key:FOO:BAR)``
457+
Retrieves the value associated with the key ``FOO`` from the array whose
458+
contents are stored in the ``BAR`` env var:
459+
460+
.. configuration-block::
461+
462+
.. code-block:: yaml
463+
464+
# config/services.yaml
465+
parameters:
466+
env(SECRETS_FILE): '/opt/application/.secrets.json'
467+
database_password: '%env(key:database_password:json:file:SECRETS_FILE)%'
468+
# if SECRETS_FILE contents are: {"database_password": "secret"} it returns "secret"
469+
470+
.. code-block:: xml
471+
472+
<!-- config/services.xml -->
473+
<?xml version="1.0" encoding="UTF-8" ?>
474+
<container xmlns="http://symfony.com/schema/dic/services"
475+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
476+
xmlns:framework="http://symfony.com/schema/dic/symfony"
477+
xsi:schemaLocation="http://symfony.com/schema/dic/services
478+
http://symfony.com/schema/dic/services/services-1.0.xsd
479+
http://symfony.com/schema/dic/symfony
480+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
481+
482+
<parameters>
483+
<parameter key="env(SECRETS_FILE)">/opt/application/.secrets.json</parameter>
484+
<parameter key="database_password">%env(key:database_password:json:file:SECRETS_FILE)%</parameter>
485+
</parameters>
486+
</container>
487+
488+
.. code-block:: php
489+
490+
// config/services.php
491+
$container->setParameter('env(SECRETS_FILE)', '/opt/application/.secrets.json');
492+
$container->setParameter('database_password', '%env(key:database_password:json:file:SECRETS_FILE)%');
493+
494+
.. versionadded:: 4.2
495+
The ``key`` processor was introduced in Symfony 4.2.
496+
456497
It is also possible to combine any number of processors:
457498

458499
.. code-block:: yaml

0 commit comments

Comments
 (0)
0