Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Enum Bundle

Enum Bundle Laravel Package

lamoda/enum-bundle

Lamoda EnumBundle is a lightweight Symfony bundle for modeling enumerated values as typed PHP classes, with labels, validation, Doctrine DBAL mapping, and form choice integration, helping teams keep reusable enum definitions consistent across domain logic and UI in Symfony applications.

View on GitHub
Deep Wiki
Context7

Lamoda Enum Bundle is a Symfony bundle for working with PHP enumeration objects across your application. It bridges enums with Symfony’s form, validation, and Doctrine layers, reducing boilerplate when exposing fixed value sets in UI and persistence code.

  • Symfony form type for enum-backed choices
  • Doctrine support for persisting enum values
  • Integration with validators and Twig helpers
  • Configurable enum classes and labels
  • Lightweight, framework-native setup
Frequently asked questions about Enum Bundle
Does lamoda/enum-bundle work with Laravel?
No. Despite being filed under Laravel/PHP, lamoda/enum-bundle is a Symfony bundle whose entire value is framework glue: a Bundle class, a DI extension, compiler passes, a Doctrine DBAL type, a Symfony Form EnumType, a validator constraint, and Twig helpers. Laravel has no equivalent subsystems for bundle registration, compiler passes, the Form component, or Twig, so the package is effectively inert in a Laravel application. Installing it would pull in symfony/form, symfony/validator, symfony/twig-bridge, and Doctrine bridge code you cannot use.
What is the difference between lamoda/enum-bundle and native PHP 8.1 enums for Laravel?
The bundle wraps paillechat/php-enum, which is the pre-8.1 pattern of classes extending a base Enum with class constants. PHP 8.1+ native backed enums already handle typed values, JSON serialization, and comparison with zero dependencies. Laravel's Rule::enum validation rule and Eloquent enum casts cover roughly 90% of what this bundle offers. Adopting the bundle in a Laravel codebase means introducing a second, non-idiomatic enum vocabulary for marginal gain.
How do I validate an enum in Laravel without this package?
Use Laravel's built-in Rule::enum validation rule, for example Rule::enum(Status::class) inside your FormRequest rules array. It works with any native PHP 8.1 backed enum and requires no third-party dependency. If you need custom behavior, an invokable rule class is a few lines of code. This replaces the validator constraint that lamoda/enum-bundle provides for Symfony.
How do I cast an enum column in Eloquent instead of using a Doctrine DBAL type?
Native enum casts are supported directly in Eloquent: declare protected $casts = ['status' => Status::class] on your model and Laravel handles conversion between the database value and the enum instance. This removes the need for the Doctrine DBAL type the bundle registers. Backed enums also serialize to JSON automatically, so API responses need no extra mapping layer.
Is lamoda/enum-bundle actively maintained?
Signals suggest not in a community sense. The repository has around 10 stars, zero dependents, and a last release of February 2024, and it appears to be a corporate utility from Lamoda's Symfony estate rather than a community-maintained library. There is no visible CVE process, issue triage cadence, or downstream cohort to absorb breakage before it reaches you. The MIT license means forking is legally trivial, but forking means you own the maintenance.
What PHP version does lamoda/enum-bundle require, and does it support 8.3 or 8.4?
The package predates broad PHP 8.3 and 8.4 adoption given its February 2024 release, so upper-bound support is unproven and should be verified against the composer.json constraint range. Run composer why-not against your target PHP and Symfony versions before committing. If your floor is PHP 8.1 or higher, native enums are the simpler default answer anyway.
What does lamoda/enum-bundle actually provide under the hood?
It provides Symfony integration for paillechat/php-enum: a Bundle class, a dependency injection extension, compiler passes that tag enum-aware services, a Doctrine DBAL type for enum columns, a Symfony Form EnumType, a validator constraint, and Twig helpers. None of those components have Laravel equivalents, so the bundle's functionality does not translate. The underlying abstraction is the pre-8.1 class-constant enum pattern rather than native PHP enums.
What is the best alternative to lamoda/enum-bundle for a Laravel project?
Standardize on native PHP 8.1 backed enums, then add a thin internal layer where needed: a validation rule, an Eloquent cast, and a small helper for label or option lists. That is roughly 150 lines of code, one day of work, and no third-party surface area. It also survives every future Laravel and PHP upgrade without constraint conflicts.
Can I install lamoda/enum-bundle in Laravel and shim the Symfony bundle machinery?
You can technically install it, but the effort exceeds the cost of writing the equivalent internally and leaves a permanent abstraction mismatch. You would be maintaining shims for a bundle class, a DI extension, compiler passes, and Form and Twig integrations that Laravel does not run. Do not attempt this; the package earns its keep only in a genuine Symfony application with Doctrine.
When should I actually adopt lamoda/enum-bundle instead of skipping it?
Adopt it only if the target service is genuinely Symfony with Doctrine DBAL, where it is a natural low-ceremony fit: register the bundle in bundles.php, map enum classes to DBAL types in doctrine.yaml, and use EnumType in forms. Even then, spike it for no more than three days, confirm the symfony component constraint range, and wrap access behind an internal helper so removal is a one-file change. If the target is Laravel or framework-agnostic, skip the dependency entirely.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo