Skip to content

Commit 9eec4af

Browse files
committed
Add missing configurations in XML and PHP formats
1 parent 564ff55 commit 9eec4af

File tree

1 file changed

+82
-14
lines changed

1 file changed

+82
-14
lines changed

configuration/env_var_processors.rst

+82-14
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,42 @@ Symfony provides the following env var processors:
279279
``env(csv:FOO)``
280280
Decodes the content of ``FOO``, which is a CSV-encoded string:
281281

282-
.. code-block:: yaml
282+
.. configuration-block::
283283

284-
parameters:
285-
env(TRUSTED_HOSTS): "10.0.0.1, 10.0.0.2"
286-
framework:
287-
trusted_hosts: '%env(csv:TRUSTED_HOSTS)%'
284+
.. code-block:: yaml
285+
286+
# config/packages/framework.yaml
287+
parameters:
288+
env(TRUSTED_HOSTS): "10.0.0.1, 10.0.0.2"
289+
framework:
290+
trusted_hosts: '%env(csv:TRUSTED_HOSTS)%'
291+
292+
.. code-block:: xml
293+
294+
<!-- config/packages/framework.xml -->
295+
<?xml version="1.0" encoding="UTF-8" ?>
296+
<container xmlns="http://symfony.com/schema/dic/services"
297+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
298+
xmlns:framework="http://symfony.com/schema/dic/symfony"
299+
xsi:schemaLocation="http://symfony.com/schema/dic/services
300+
https://symfony.com/schema/dic/services/services-1.0.xsd
301+
http://symfony.com/schema/dic/symfony
302+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
303+
304+
<parameters>
305+
<parameter key="env(TRUSTED_HOSTS)">["10.0.0.1", "10.0.0.2"]</parameter>
306+
</parameters>
307+
308+
<framework:config trusted-hosts="%env(csv:TRUSTED_HOSTS)%"/>
309+
</container>
310+
311+
.. code-block:: php
312+
313+
// config/packages/framework.php
314+
$container->setParameter('env(TRUSTED_HOSTS)', '["10.0.0.1", "10.0.0.2"]');
315+
$container->loadFromExtension('framework', [
316+
'trusted_hosts' => '%env(csv:TRUSTED_HOSTS)%',
317+
]);
288318
289319
``env(file:FOO)``
290320
Returns the contents of a file whose path is the value of the ``FOO`` env var:
@@ -627,16 +657,54 @@ Symfony provides the following env var processors:
627657

628658
It is also possible to combine any number of processors:
629659

630-
.. code-block:: yaml
660+
.. configuration-block::
661+
662+
.. code-block:: yaml
631663
632-
parameters:
633-
env(AUTH_FILE): "%kernel.project_dir%/config/auth.json"
634-
google:
635-
# 1. gets the value of the AUTH_FILE env var
636-
# 2. replaces the values of any config param to get the config path
637-
# 3. gets the content of the file stored in that path
638-
# 4. JSON-decodes the content of the file and returns it
639-
auth: '%env(json:file:resolve:AUTH_FILE)%'
664+
# config/packages/framework.yaml
665+
parameters:
666+
env(AUTH_FILE): "%kernel.project_dir%/config/auth.json"
667+
google:
668+
# 1. gets the value of the AUTH_FILE env var
669+
# 2. replaces the values of any config param to get the config path
670+
# 3. gets the content of the file stored in that path
671+
# 4. JSON-decodes the content of the file and returns it
672+
auth: '%env(json:file:resolve:AUTH_FILE)%'
673+
674+
.. code-block:: xml
675+
676+
<!-- config/packages/framework.xml -->
677+
<?xml version="1.0" encoding="UTF-8" ?>
678+
<container xmlns="http://symfony.com/schema/dic/services"
679+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
680+
xmlns:framework="http://symfony.com/schema/dic/symfony"
681+
xsi:schemaLocation="http://symfony.com/schema/dic/services
682+
https://symfony.com/schema/dic/services/services-1.0.xsd
683+
http://symfony.com/schema/dic/symfony
684+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
685+
686+
<parameters>
687+
<parameter key="env(AUTH_FILE)">%kernel.project_dir%/config/auth.json</parameter>
688+
</parameters>
689+
690+
<!-- 1. gets the value of the AUTH_FILE env var -->
691+
<!-- 2. replaces the values of any config param to get the config path -->
692+
<!-- 3. gets the content of the file stored in that path -->
693+
<!-- 4. JSON-decodes the content of the file and returns it -->
694+
<google auth="%env(json:file:resolve:AUTH_FILE)%"/>
695+
</container>
696+
697+
.. code-block:: php
698+
699+
// config/packages/framework.php
700+
$container->setParameter('env(AUTH_FILE)', '%kernel.project_dir%/config/auth.json');
701+
// 1. gets the value of the AUTH_FILE env var
702+
// 2. replaces the values of any config param to get the config path
703+
// 3. gets the content of the file stored in that path
704+
// 4. JSON-decodes the content of the file and returns it
705+
$container->loadFromExtension('google', [
706+
'auth' => '%env(json:file:resolve:AUTH_FILE)%',
707+
]);
640708
641709
Custom Environment Variable Processors
642710
--------------------------------------

0 commit comments

Comments
 (0)