Skip to content

Commit f36b2a6

Browse files
committed
Add documentation for the require env processor
1 parent 337a9e2 commit f36b2a6

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

configuration/environment_variables.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,47 @@ Symfony provides the following env var processors:
445445
'auth' => '%env(file:AUTH_FILE)%',
446446
]);
447447
448+
``env(require:FOO)``
449+
``require()`` the PHP file whose path is the value of the ``FOO``
450+
env var and return the value ``return``ed from it.
451+
452+
.. configuration-block::
453+
454+
.. code-block:: yaml
455+
456+
# config/packages/framework.yaml
457+
parameters:
458+
env(PHP_FILE): '../config/.runtime-evaluated.php'
459+
app:
460+
auth: '%env(require:PHP_FILE)%'
461+
462+
.. code-block:: xml
463+
464+
<!-- config/packages/framework.xml -->
465+
<?xml version="1.0" encoding="UTF-8" ?>
466+
<container xmlns="http://symfony.com/schema/dic/services"
467+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
468+
xmlns:framework="http://symfony.com/schema/dic/symfony"
469+
xsi:schemaLocation="http://symfony.com/schema/dic/services
470+
https://symfony.com/schema/dic/services/services-1.0.xsd
471+
http://symfony.com/schema/dic/symfony
472+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
473+
474+
<parameters>
475+
<parameter key="env(PHP_FILE)">../config/.runtime-evaluated.php</parameter>
476+
</parameters>
477+
478+
<app auth="%env(require:PHP_FILE)%"/>
479+
</container>
480+
481+
.. code-block:: php
482+
483+
// config/packages/framework.php
484+
$container->setParameter('env(PHP_FILE)', '../config/.runtime-evaluated.php');
485+
$container->loadFromExtension('app', [
486+
'auth' => '%env(require:AUTH_FILE)%',
487+
]);
488+
448489
``env(trim:FOO)``
449490
Trims the content of ``FOO`` env var, removing whitespaces from the beginning
450491
and end of the string. This is especially useful in combination with the

0 commit comments

Comments
 (0)