File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -741,11 +741,13 @@ Symfony provides the following env var processors:
741
741
Tries to convert an environment variable to an actual ``\BackedEnum `` value.
742
742
This processor takes the fully qualified name of the ``\BackedEnum `` as an argument::
743
743
744
- # App\Enum\Environment
744
+ // App\Enum\Suit.php
745
745
enum Environment: string
746
746
{
747
- case Development = 'dev';
748
- case Production = 'prod';
747
+ case Clubs = 'clubs';
748
+ case Spades = 'spades';
749
+ case Diamonds = 'diamonds';
750
+ case Hearts = 'hearts';
749
751
}
750
752
751
753
.. configuration-block ::
@@ -754,7 +756,7 @@ Symfony provides the following env var processors:
754
756
755
757
# config/services.yaml
756
758
parameters :
757
- typed_env : ' %env(enum:App\Enum\Environment:APP_ENV )%'
759
+ suit : ' %env(enum:App\Enum\Suit:CARD_SUIT )%'
758
760
759
761
.. code-block :: xml
760
762
@@ -769,14 +771,17 @@ Symfony provides the following env var processors:
769
771
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
770
772
771
773
<parameters >
772
- <parameter key =" typed_env " >%env(enum:App\Enum\Environment:APP_ENV )%</parameter >
774
+ <parameter key =" suit " >%env(enum:App\Enum\Suit:CARD_SUIT )%</parameter >
773
775
</parameters >
774
776
</container >
775
777
776
778
.. code-block :: php
777
779
778
780
// config/services.php
779
- $container->setParameter('typed_env', '%env(enum:App\Enum\Environment:APP_ENV)%');
781
+ $container->setParameter('suit', '%env(enum:App\Enum\Suit:CARD_SUIT)%');
782
+
783
+ The value stored in the ``CARD_SUIT `` env var would be a string (e.g. ``'spades' ``)
784
+ but the application will use the enum value (e.g. ``Suit::Spades ``).
780
785
781
786
``env(defined:NO_FOO) ``
782
787
Evaluates to ``true `` if the env var exists and its value is not ``'' ``
You can’t perform that action at this time.
0 commit comments