@@ -446,6 +446,15 @@ Symfony provides the following env var processors:
446446 'auth' => '%env(file:AUTH_FILE)%',
447447 ]);
448448
449+ ``env(trim:FOO) ``
450+ Trims the content of ``FOO `` env var, removing whitespaces from the beginning
451+ and end of the string. This is especially useful in combination with the
452+ ``file `` processor, as it'll remove newlines at the end of a file.
453+
454+ .. versionadded :: 4.3
455+
456+ The ``trim `` processor was introduced in Symfony 4.3.
457+
449458``env(key:FOO:BAR) ``
450459 Retrieves the value associated with the key ``FOO `` from the array whose
451460 contents are stored in the ``BAR `` env var:
@@ -484,6 +493,50 @@ Symfony provides the following env var processors:
484493 $container->setParameter('env(SECRETS_FILE)', '/opt/application/.secrets.json');
485494 $container->setParameter('database_password', '%env(key:database_password:json:file:SECRETS_FILE)%');
486495
496+ ``env(default:fallback_param:BAR) ``
497+ Retrieves the value of the parameter ``fallback_param `` when the ``BAR `` env
498+ var is not available:
499+
500+ .. configuration-block ::
501+
502+ .. code-block :: yaml
503+
504+ # config/services.yaml
505+ parameters :
506+ # if PRIVATE_KEY is not a valid file path, the content of raw_key is returned
507+ private_key : ' %env(default:raw_key:file:PRIVATE_KEY)%'
508+ raw_key : ' %env(PRIVATE_KEY)%'
509+
510+ .. code-block :: xml
511+
512+ <!-- config/services.xml -->
513+ <?xml version =" 1.0" encoding =" UTF-8" ?>
514+ <container xmlns =" http://symfony.com/schema/dic/services"
515+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
516+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
517+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
518+ http://symfony.com/schema/dic/services/services-1.0.xsd
519+ http://symfony.com/schema/dic/symfony
520+ http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
521+ <parameters >
522+ <!-- if PRIVATE_KEY is not a valid file path, the content of raw_key is returned -->
523+ <parameter key =" private_key" >%env(default:raw_key:file:PRIVATE_KEY)%</parameter >
524+ <parameter key =" raw_key" >%env(PRIVATE_KEY)%</parameter >
525+ </parameters >
526+ </container >
527+
528+ .. code-block :: php
529+
530+ // config/services.php
531+
532+ // if PRIVATE_KEY is not a valid file path, the content of raw_key is returned
533+ $container->setParameter('private_key', '%env(default:raw_key:file:PRIVATE_KEY)%');
534+ $container->setParameter('raw_key', '%env(PRIVATE_KEY)%');
535+
536+ .. versionadded :: 4.3
537+
538+ The ``default `` processor was introduced in Symfony 4.3.
539+
487540It is also possible to combine any number of processors:
488541
489542.. code-block :: yaml
0 commit comments