Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc1bcf07

Browse files
committed
minor#10722 Add env default processor (jderusse)
This PR was merged into the master branch.Discussion----------Add env default processorThis PR documentssymfony/symfony#28976Commits-------8d3afcc Add env default processor
2 parents9c1f0a3 +8d3afcc commitc1bcf07

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

‎configuration/external_parameters.rst‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,46 @@ Symfony provides the following env var processors:
497497
$container->setParameter('env(SECRETS_FILE)', '/opt/application/.secrets.json');
498498
$container->setParameter('database_password', '%env(key:database_password:json:file:SECRETS_FILE)%');
499499
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+
<containerxmlns="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+
<parameterkey="private_key">%env(default:raw_key:file:PRIVATE_KEY)%</parameter>
527+
<parameterkey="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+
500540
It is also possible to combine any number of processors:
501541

502542
..code-block::yaml

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp