Skip to content

Installation

phil/enums-bundle

Requirements

RequirementWhy
PHP 8.5 or later, ext-mbstringThe generated translation keys lower-case case names that may hold letters outside ASCII.
phil/enumsThe metadata (Label, Description, Group), the metadata reader and CaseCollection.
symfony/form, symfony/options-resolverThe EnumType extension.
symfony/validatorThe EnumCase constraint.
symfony/translation-contractsTranslatableInterface, which translatable enums implement.
twig/twigThe Twig functions and filters.
symfony/dependency-injection, symfony/configThe bundle class and its configuration.
ext-tokenizerThe finder of the commands and of the translation extractor reads PHP files by their tokens.

Several packages are optional: the bundle registers what needs them only when they are installed, and suggests them.

Optional packageEnables
symfony/translationThe translation extractor, and the translation check of debug:enums (Translation).
symfony/consoleThe commands debug:enums and phil:enums:typescript (Commands).
symfony/serializerThe normalizer of enum sets, enum maps and labelled cases (APIs).
doctrine/dbalThe EnumSet column types (Doctrine).
doctrine/ormThe phil:enums:check-sets command.
symfony/http-kernelThe #[ParseEnum] controller argument resolver.
symfony/expression-languageThe expression functions.
api-platform/symfonyThe enum schemas of API Platform resources (APIs).
nelmio/api-doc-bundleThe enum schemas of NelmioApiDoc models (APIs).
symfony/maker-bundlemake:enum (Commands).
symfony/workflowThe state machines built from #[TransitionsTo] (Routing, expressions and workflows).

The application registers FrameworkBundle, and TwigBundle for the Twig part: the bundle tags its services for them (form.type_extension, validator.constraint_validator, twig.attribute_extension, twig.runtime) and uses the translator service when there is one.

Installing

composer require phil/enums-bundle
// config/bundles.php
return [
    // …
    Phil\EnumsBundle\PhilEnumsBundle::class => ['all' => true],
];

Its configuration is optional: see Configuration.