Skip to content

Commit 49b74d5

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Add missing configurations in XML and PHP formats
2 parents 62e5004 + 8d947f9 commit 49b74d5

File tree

1 file changed

+82
-14
lines changed

1 file changed

+82
-14
lines changed

configuration/env_var_processors.rst

Lines changed: 82 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,42 @@ Symfony provides the following env var processors:
281281
``env(csv:FOO)``
282282
Decodes the content of ``FOO``, which is a CSV-encoded string:
283283

284-
.. code-block:: yaml
284+
.. configuration-block::
285285

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

612-
.. code-block:: yaml
642+
.. configuration-block::
643+
644+
.. code-block:: yaml
613645
614-
parameters:
615-
env(AUTH_FILE): "%kernel.project_dir%/config/auth.json"
616-
google:
617-
# 1. gets the value of the AUTH_FILE env var
618-
# 2. replaces the values of any config param to get the config path
619-
# 3. gets the content of the file stored in that path
620-
# 4. JSON-decodes the content of the file and returns it
621-
auth: '%env(json:file:resolve:AUTH_FILE)%'
646+
# config/packages/framework.yaml
647+
parameters:
648+
env(AUTH_FILE): "%kernel.project_dir%/config/auth.json"
649+
google:
650+
# 1. gets the value of the AUTH_FILE env var
651+
# 2. replaces the values of any config param to get the config path
652+
# 3. gets the content of the file stored in that path
653+
# 4. JSON-decodes the content of the file and returns it
654+
auth: '%env(json:file:resolve:AUTH_FILE)%'
655+
656+
.. code-block:: xml
657+
658+
<!-- config/packages/framework.xml -->
659+
<?xml version="1.0" encoding="UTF-8" ?>
660+
<container xmlns="http://symfony.com/schema/dic/services"
661+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
662+
xmlns:framework="http://symfony.com/schema/dic/symfony"
663+
xsi:schemaLocation="http://symfony.com/schema/dic/services
664+
https://symfony.com/schema/dic/services/services-1.0.xsd
665+
http://symfony.com/schema/dic/symfony
666+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
667+
668+
<parameters>
669+
<parameter key="env(AUTH_FILE)">%kernel.project_dir%/config/auth.json</parameter>
670+
</parameters>
671+
672+
<!-- 1. gets the value of the AUTH_FILE env var -->
673+
<!-- 2. replaces the values of any config param to get the config path -->
674+
<!-- 3. gets the content of the file stored in that path -->
675+
<!-- 4. JSON-decodes the content of the file and returns it -->
676+
<google auth="%env(json:file:resolve:AUTH_FILE)%"/>
677+
</container>
678+
679+
.. code-block:: php
680+
681+
// config/packages/framework.php
682+
$container->setParameter('env(AUTH_FILE)', '%kernel.project_dir%/config/auth.json');
683+
// 1. gets the value of the AUTH_FILE env var
684+
// 2. replaces the values of any config param to get the config path
685+
// 3. gets the content of the file stored in that path
686+
// 4. JSON-decodes the content of the file and returns it
687+
$container->loadFromExtension('google', [
688+
'auth' => '%env(json:file:resolve:AUTH_FILE)%',
689+
]);
622690
623691
Custom Environment Variable Processors
624692
--------------------------------------

0 commit comments

Comments
 (0)