-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add env default processor #10722
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
Add env default processor #10722
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 |
---|---|---|
|
@@ -494,6 +494,46 @@ Symfony provides the following env var processors: | |
.. versionadded:: 4.2 | ||
The ``key`` processor was introduced in Symfony 4.2. | ||
|
||
``env(default:fallback_param:BAR)`` | ||
Retrieves the value of the parameter ``fallback_param`` when the of the ``BAR`` env var is not available: | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
|
||
# config/services.yaml | ||
parameters: | ||
private_key: '%env(default:raw_key:file:PRIVATE_KEY)%' | ||
raw_key: '%env(PRIVATE_KEY)%' | ||
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. I wonder if we could put a hardcoded path/value for 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.. Using the same variable to define both private key AND raw key was a IMO a great use case for the default processor and a convenient way to configure a bundle for instance. If we remove the double use of the same variable, we should find a totally example. What's about case where "injected secret file does not exists" (or variable not provided at all)?
|
||
# if PRIVATE_KEY is not a valid file path, the content of raw_key is returned. | ||
|
||
.. 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 | ||
http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony | ||
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
|
||
<parameters> | ||
<parameter key="private_key">%env(default:raw_key:file:PRIVATE_KEY)%</parameter> | ||
<parameter key="raw_key">%env(PRIVATE_KEY)%</parameter> | ||
</parameters> | ||
</container> | ||
|
||
.. code-block:: php | ||
|
||
// config/services.php | ||
$container->setParameter('private_key', '%env(default:raw_key:file:PRIVATE_KEY)%'); | ||
$container->setParameter('raw_key', '%env(PRIVATE_KEY)%'); | ||
|
||
.. versionadded:: 4.3 | ||
The ``default`` processor was introduced in Symfony 4.3. | ||
|
||
It is also possible to combine any number of processors: | ||
|
||
.. code-block:: yaml | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence seems to be missing some or having extra words :)