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.
OrderStatus, PaymentMethod), reducing ambiguity in domain logic and improving collaboration between developers and stakeholders. Aligns with ubiquitous language by enforcing valid states at the database and application layers.NotificationChannel::EMAIL | NotificationChannel::PUSH) with type safety and database constraints.WHERE status = 'PENDING') by leveraging native ENUM types, which are index-friendly and storage-efficient.UserRole::GUEST → UserRole::ADMIN) for compliance and debugging, with built-in support for Doctrine migrations.'1' for 'active' with UserStatus::ACTIVE).switch statements).jsonb/json column or a separate lookup table instead.*"This package lets us eliminate bugs caused by invalid state values (e.g., 'active' vs. 1 for user status) by enforcing type-safe enums in our Symfony backend. For example:
order_status = 'invalid') are caught at the database level, not in runtime errors.switch statements for state transitions—just annotate your entities and go.Use Cases:
OrderStatus (e.g., PENDING, SHIPPED, CANCELLED) with database constraints.PaymentMethod enums (e.g., CREDIT_CARD, PAYPAL) for feature flags.UserRole::GUEST → UserRole::ADMIN).Risk: Minimal—MIT-licensed, 462+ stars, and used in production by other teams. We can pilot it with a single entity (e.g., UserRole) before full adoption."*
*"DoctrineEnumBundle gives us native ENUM support in Doctrine/Symfony with zero trade-offs for our stack: ✅ What You Get:
ORDER_STATUS can’t be 'invalid').select2 with UserStatus::values()).{% if order.status == App\Enum\OrderStatus::SHIPPED %}).🔧 How to Adopt:
UserRole) to validate migrations, forms, and Twig workflows.⚠️ Caveats:
App\Enum\Status::ACTIVE in Twig, not strings.Example Migration:
// Before: Manual validation + strings
$order->setStatus('shipped'); // Risk of typos!
// After: Type-safe + database constraint
$order->setStatus(OrderStatus::SHIPPED); // Caught at compile time.
Next Steps:
composer.json (fresh/doctrine-enum-bundle).config/bundles.php (Symfony Flex handles this by default).Order)."*How can I help you explore Laravel packages today?