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:
741741 Tries to convert an environment variable to an actual ``\BackedEnum `` value.
742742 This processor takes the fully qualified name of the ``\BackedEnum `` as an argument::
743743
744- # App\Enum\Environment
744+ // App\Enum\Suit.php
745745 enum Environment: string
746746 {
747- case Development = 'dev';
748- case Production = 'prod';
747+ case Clubs = 'clubs';
748+ case Spades = 'spades';
749+ case Diamonds = 'diamonds';
750+ case Hearts = 'hearts';
749751 }
750752
751753 .. configuration-block ::
@@ -754,7 +756,7 @@ Symfony provides the following env var processors:
754756
755757 # config/services.yaml
756758 parameters :
757- typed_env : ' %env(enum:App\Enum\Environment:APP_ENV )%'
759+ suit : ' %env(enum:App\Enum\Suit:CARD_SUIT )%'
758760
759761 .. code-block :: xml
760762
@@ -769,14 +771,17 @@ Symfony provides the following env var processors:
769771 https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
770772
771773 <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 >
773775 </parameters >
774776 </container >
775777
776778 .. code-block :: php
777779
778780 // 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 ``).
780785
781786``env(defined:NO_FOO) ``
782787 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