fresh/doctrine-enum-bundle
Symfony bundle adding ENUM type support to Doctrine ORM/DBAL. Register custom enum types and map them to entity fields for safer, consistent values across databases. Works with modern Symfony/Doctrine versions and common platforms like PostgreSQL, MySQL, SQLite, and MSSQL.
postGenerateSchemaCommand).enum_values Twig filter, EnumType form field).UserStatus::ACTIVE vs. "active"), reducing runtime errors and improving IDE support (PhpStorm, VSCode).#[EnumType]) or annotations, with minimal additional configuration.fresh/doctrine-enum-bundle) and configure in bundles.php. ENUM columns are created automatically during schema generation.ALTER TABLE user ADD CONSTRAINT enum_user_status CHECK (status IN ('active', 'inactive'))).EnumType form field auto-generates choices from ENUM constants.enum_values() filter renders human-readable labels (e.g., {% set statusLabel = enum_values(order.status) %}).v11.2.* (supports PHP 8.2, Symfony 6.4).enum_values() requires runtime reflection to map ENUM constants to labels, adding minimal CPU cost.#[EnumType]) may need training.VARCHAR → ENUM) requires downtime or careful transaction handling.nullable: true in EnumType).jsonb or array columns instead).OrderStatus) before full rollout?VARCHAR → ENUM migrations)?Stof\DoctrineExtensionsBundle) for similar functionality?OrderStatus, UserRole).string + validation).jsonb or array columns instead.#[EnumType]) and migration steps.UserRole or OrderStatus.// src/Entity/UserRole.php
use Fresh\DoctrineEnumBundle\Attributes\EnumType;
#[EnumType]
private UserRoleEnum $role;
php bin/console make:migration
EnumType form fields and Twig filters work.VARCHAR/INT fields with ENUMs in new code.doctrine/doctrine-bundle is up-to-date.EnumType integrates with Symfony’s form system.enum_values filter works with Twig 2.12+.@Assert\Type).@Enum for older Symfony versions (deprecated in favor of attributes).private ?string $legacyStatus).bundles.php.#[EnumType] to a pilot entity.How can I help you explore Laravel packages today?