Skip to content

Configuration

phil/enums-bundle

The alias is phil_enums. Three keys, all optional:

# config/packages/phil_enums.yaml
phil_enums:
    # Where debug:enums and phil:enums:typescript look for enums: directories or files.
    paths: ['%kernel.project_dir%/src']

    doctrine:
        # DBAL types that store an EnumSet, by type name (see Doctrine).
        sets:
            permissions: { enum: App\Security\Permission, storage: bitmask }
            channels: { enum: App\Notification\Channel }   # storage: json, the default

    # Symfony state machines built from the #[TransitionsTo] of an enum, by workflow name.
    workflows:
        order: { enum: App\Order\OrderStatus, supports: [App\Order\Order], property: status }
KeyDefaultMeaning
paths['%kernel.project_dir%/src']The directories and files the commands read for enum declarations (Commands).
doctrine.sets.<name>.enumrequiredThe enum of the set; a class that is not an enum fails the container build.
doctrine.sets.<name>.storagejsonbitmask — one integer, for an enum of bit flags — or json — a JSON list of values (Doctrine).
workflows.<name>.enumrequiredA backed enum whose cases declare #[TransitionsTo] (Routing, expressions and workflows).
workflows.<name>.supportsrequiredThe classes the workflow applies to; at least one.
workflows.<name>.propertystatusThe property that holds the case.

What varies per enum — its translation domain and key prefix, its groups, its colour — is declared on the enum itself, never here.

Services

The bundle registers each service as soon as it is installed, or — for the integrations — as soon as the package the service needs is. Each acts only on what asks for it.

ServiceTagsRegisteredActs on
Infrastructure\Form\EnumTypeExtensionform.type_extensionAlwaysEvery EnumType field; changes nothing without the options of Forms, except labels.
Infrastructure\Form\EnumSetTypeform.typeAlwaysFields of EnumSet data (Forms).
Infrastructure\Validator\EnumCaseValidator, Infrastructure\Validator\EnumSetOfValidatorvalidator.constraint_validatorAlwaysThe EnumCase and EnumSetOf constraints (Validation).
Infrastructure\Validator\TransitionValidatorvalidator.constraint_validatorAlways; given the doctrine service when there is oneThe Transition constraint: it reads the previous case from Doctrine's unit of work, or from the object alone without Doctrine (Validation).
Infrastructure\Twig\EnumsExtensiontwig.attribute_extension, twig.runtimeAlwaysThe Twig functions and filters (Twig).
Infrastructure\Translation\EnumTranslationExtractortranslation.extractor (alias phil_enums)With symfony/translationtranslation:extract (Translation).
Infrastructure\Console\DebugEnumsCommand, Infrastructure\Console\ExportTypeScriptCommand, Infrastructure\Console\ExportIcuCommandconsole.commandWith symfony/consoledebug:enums, phil:enums:typescript and phil:enums:icu (Commands).
Infrastructure\Console\CheckSetColumnsCommandconsole.commandWith symfony/console and doctrine/ormphil:enums:check-sets (Doctrine).
Infrastructure\Http\ParsedEnumValueResolvercontroller.argument_value_resolverWith symfony/http-kernelArguments marked #[ParseEnum] (Routing, expressions and workflows).
Infrastructure\ExpressionLanguage\EnumsExpressionProvidersecurity., routing. and validator.expression_language_providerWith symfony/expression-languageenum_meta(), enum_in_group(), enum_from().
Infrastructure\OpenApi\NelmioEnumModelDescribernelmio_api_doc.model_describer, before nelmio_api_doc.model_describers.enumWith nelmio/api-doc-bundleEnum models (APIs).
Infrastructure\OpenApi\ApiPlatformEnumPropertyMetadataFactorydecorates api_platform.metadata.property.metadata_factory, around its schema decorator and within its cacheWith api-platform/symfonyEnum properties of resources (APIs).
Infrastructure\Maker\MakeEnummaker.commandWith symfony/maker-bundlemake:enum (Commands).
Infrastructure\Serializer\EnumsNormalizerserializer.normalizer, before Symfony's normalizers of translatable values, enum cases and objectsWith symfony/serializerEnum sets, enum maps, and labelled cases (APIs).

Every service that shows a label receives the translator service, or nothing when there is none. The EnumSet column types are not services: the bundle registers them in DBAL's type registry when it boots, with doctrine/dbal installed (Doctrine). The workflows are not services of the bundle either: it prepends them to FrameworkBundle's workflows, with symfony/workflow installed.