-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add docs for the yaml
env var processor
#11321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -354,6 +354,47 @@ Symfony provides the following env var processors: | |
'trusted_hosts' => '%env(json:TRUSTED_HOSTS)%', | ||
]); | ||
|
||
``env(yaml:FOO)`` | ||
Decodes the content of ``FOO``, which is a YAML encoded string. It returns | ||
either an array or ``null``. Mostly useful in combination with | ||
``file``: | ||
|
||
.. code-block:: yaml | ||
|
||
# config/services.yaml | ||
parameters: | ||
env(SECRETS_FILE): '/opt/application/.secrets.yaml' | ||
database_password: '%env(key:database_password:yaml:file:SECRETS_FILE)%' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we change the example and remove the key:database_password processor here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @OskarStark To make the example more concise? Would you ever use an array value as such? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm not sure, I haven’t any other example |
||
# if SECRETS_FILE contents are: 'database_password: secret' it returns "secret" | ||
|
||
.. code-block:: xml | ||
|
||
<!-- config/services.xml --> | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services | ||
https://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony | ||
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
|
||
<parameters> | ||
<parameter key="env(SECRETS_FILE)">/opt/application/.secrets.yaml</parameter> | ||
<parameter key="database_password">%env(key:database_password:yaml:file:SECRETS_FILE)%</parameter> | ||
</parameters> | ||
</container> | ||
|
||
.. code-block:: php | ||
|
||
// config/services.php | ||
$container->setParameter('env(SECRETS_FILE)', '/opt/application/.secrets.yaml'); | ||
$container->setParameter('database_password', '%env(key:database_password:yaml:file:SECRETS_FILE)%'); | ||
|
||
.. versionadded:: 4.3 | ||
|
||
The ``yaml`` processor was introduced in Symfony 4.3. | ||
|
||
``env(resolve:FOO)`` | ||
Replaces the string ``FOO`` by the value of a config parameter with the | ||
same name: | ||
|
Uh oh!
There was an error while loading. Please reload this page.