Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d83bfd1

Browse files
committed
Tweaks
1 parent cc8487d commit d83bfd1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

configuration.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,16 +674,17 @@ To define the value of an env var, you have several options:
674674
* :ref:`Encrypt the value as a secret <configuration-secrets>`;
675675
* Set the value as a real environment variable in your shell or your web server.
676676

677-
It is possible to define an env var default value by defining a parameter with
678-
the same name. In the following example, we define a default value for the
679-
``SECRET`` env var if it has not been defined anywhere:
677+
If your application tries to use an env var that hasn't been defined, you'll see
678+
an exception. You can prevent that by defining a default value for the env var.
679+
To do so, define a parameter with the same name as the env var using this syntax:
680680

681681
.. configuration-block::
682682

683683
.. code-block:: yaml
684684
685685
# config/packages/framework.yaml
686686
parameters:
687+
# if the SECRET env var value is not defined anywhere, Symfony uses this value
687688
env(SECRET): 'some_secret'
688689
689690
# ...
@@ -701,6 +702,7 @@ the same name. In the following example, we define a default value for the
701702
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
702703
703704
<parameters>
705+
<!-- if the SECRET env var value is not defined anywhere, Symfony uses this value -->
704706
<parameter key="env(SECRET)">some_secret</parameter>
705707
</parameters>
706708
@@ -716,6 +718,7 @@ the same name. In the following example, we define a default value for the
716718
use Symfony\Config\FrameworkConfig;
717719
718720
return static function (ContainerBuilder $container, FrameworkConfig $framework) {
721+
// if the SECRET env var value is not defined anywhere, Symfony uses this value
719722
$container->setParameter('env(SECRET)', 'some_secret');
720723
721724
// ...

0 commit comments

Comments
 (0)