@@ -674,16 +674,17 @@ To define the value of an env var, you have several options:
674
674
* :ref: `Encrypt the value as a secret <configuration-secrets >`;
675
675
* Set the value as a real environment variable in your shell or your web server.
676
676
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 :
680
680
681
681
.. configuration-block ::
682
682
683
683
.. code-block :: yaml
684
684
685
685
# config/packages/framework.yaml
686
686
parameters :
687
+ # if the SECRET env var value is not defined anywhere, Symfony uses this value
687
688
env(SECRET) : ' some_secret'
688
689
689
690
# ...
@@ -701,6 +702,7 @@ the same name. In the following example, we define a default value for the
701
702
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
702
703
703
704
<parameters >
705
+ <!-- if the SECRET env var value is not defined anywhere, Symfony uses this value -->
704
706
<parameter key =" env(SECRET)" >some_secret</parameter >
705
707
</parameters >
706
708
@@ -716,6 +718,7 @@ the same name. In the following example, we define a default value for the
716
718
use Symfony\Config\FrameworkConfig;
717
719
718
720
return static function (ContainerBuilder $container, FrameworkConfig $framework) {
721
+ // if the SECRET env var value is not defined anywhere, Symfony uses this value
719
722
$container->setParameter('env(SECRET)', 'some_secret');
720
723
721
724
// ...
0 commit comments