@@ -497,6 +497,46 @@ Symfony provides the following env var processors:
497
497
$container->setParameter('env(SECRETS_FILE)', '/opt/application/.secrets.json');
498
498
$container->setParameter('database_password', '%env(key:database_password:json:file:SECRETS_FILE)%');
499
499
500
+ ``env(default:fallback_param:BAR) ``
501
+ Retrieves the value of the parameter ``fallback_param `` when the of the ``BAR `` env var is not available:
502
+
503
+ .. configuration-block ::
504
+
505
+ .. code-block :: yaml
506
+
507
+ # config/services.yaml
508
+ parameters :
509
+ private_key : ' %env(default:raw_key:file:PRIVATE_KEY)%'
510
+ raw_key : ' %env(PRIVATE_KEY)%'
511
+ # if PRIVATE_KEY is not a valid file path, the content of raw_key is returned.
512
+
513
+ .. code-block :: xml
514
+
515
+ <!-- config/services.xml -->
516
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
517
+ <container xmlns =" http://symfony.com/schema/dic/services"
518
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
519
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
520
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
521
+ http://symfony.com/schema/dic/services/services-1.0.xsd
522
+ http://symfony.com/schema/dic/symfony
523
+ http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
524
+
525
+ <parameters >
526
+ <parameter key =" private_key" >%en
A827
v(default:raw_key:file:PRIVATE_KEY)%</parameter >
527
+ <parameter key =" raw_key" >%env(PRIVATE_KEY)%</parameter >
528
+ </parameters >
529
+ </container >
530
+
531
+ .. code-block :: php
532
+
533
+ // config/services.php
534
+ $container->setParameter('private_key', '%env(default:raw_key:file:PRIVATE_KEY)%');
535
+ $container->setParameter('raw_key', '%env(PRIVATE_KEY)%');
536
+
537
+ .. versionadded :: 4.3
538
+ The ``default `` processor was introduced in Symfony 4.3.
539
+
500
540
It is also possible to combine any number of processors:
501
541
502
542
.. code-block :: yaml
0 commit comments