roundly-consulting/enums-for-laravel
Enums for Laravel brings first-class PHP enum support to Laravel applications. Cast enum attributes in Eloquent models, validate enum input, and work with backed values across requests and APIs. It keeps code type-safe, readable, and easy to integrate without extra boilerplate.
Architecture fit. The package is a thin convenience layer over native PHP 8.1+ enums, targeting four seams in a Laravel app: Eloquent attribute casting, form-request validation, API resource serialization, and enum label/description localization, plus Artisan generators for scaffolding. Architecturally that is a low-coupling, additive dependency — it does not own a subsystem, register service providers that alter request lifecycle, or impose a data model. It sits in the same layer as Laravel's own Illuminate\Validation\Rules\Enum and enum casts, which is the central evaluation problem: most of the advertised surface is already native. Laravel 9+ supports enum casts in $casts and Rule::enum() in validation; backed enums serialize to scalars in JSON resources by default. The genuine delta appears to be localized labels/descriptions, generator consistency, and possibly null-safe/fromName helpers. Action: require a written feature-by-feature delta against the framework baseline before adoption — if the delta is two helper methods and a generator stub, the architecture fit is technically fine but the business case is weak.
Integration feasibility. Low effort. Composer install, no infrastructure, no data migration, no queue or cache implications. A competent Laravel engineer can integrate and validate in one to three days for a pilot domain. The real cost is not integration but convention debt: once enums carry labels via a vendor interface, every enum and every Blade/JSON presentation path becomes coupled to that vendor's contract.
Technical risk.
Key questions for the maintainer / evaluation spike.
composer.json?BackedEnum vs pure enums, and tryFrom fallbacks?Stack fit. Correct fit for a Laravel 10/11 monolith or modular monolith on PHP 8.1+, where enums are already the team's chosen representation for status, type, and category fields. Poor fit for a polyglot or API-first service where Laravel is peripheral, and irrelevant for pre-8.1 runtimes. Because it is a single Composer dependency with no runtime services, the blast radius of removal is bounded to the files that reference its interfaces.
Migration path. Adopt additively, never as a refactor program:
App\Contracts\HasLabel) that the vendor contract extends, or wrap access behind a small presenter. This costs an hour and converts a vendor risk into a one-file replacement.Compatibility. Pin to an exact version in composer.json and lockfile-commit it. Confirm the package's Laravel constraint against your upgrade cadence — a package this small is unlikely to be updated promptly for a new Laravel major, and an incompatible constraint will block your framework upgrade, which is a far larger cost than the package saves. Test the package's behavior on your actual database: nullable enum columns and legacy rows containing values outside the enum are the two failure paths most likely to surface late.
Sequencing (relative to other work). Adopt after the framework is on a supported major and after the team has standardized on enums generally; adopting both at once makes it impossible to attribute problems. Do not sequence this ahead of anything with user-facing impact.
Maintenance. Expect to own it. The realistic posture is "vendored dependency with upstream": consume releases slowly, review diffs, and hold a standing option to fork under MIT. Budget a small recurring allowance — a few hours per quarter — for review, version bumps, and the framework-major compatibility check. If the maintainer goes quiet, the fork path is credible because the code surface is small; confirm that during the spike by reading the source, not by trusting the README.
Support. No SLA, no vendor contract, community-only issue triage with a 5-star project implying effectively no user base to crowdsource answers. Internal support falls to whoever owns the integration. That person should be named explicitly and documented, otherwise the package becomes orphaned knowledge the moment they change teams.
Scaling. Runtime cost is negligible — helpers on enum instances, no queries, no I/O, no caching layer. Watch two second-order effects at scale: (a) if label localization loads translation files per enum instance in a hot loop, confirm it uses the framework's already-loaded translator and does not re-read from disk; (b) label-driven presentation in list endpoints can tempt developers into per-row lookups, producing N+1 patterns that have nothing to do with the package but will be blamed on it. Both are review concerns, not capacity concerns.
Failure modes.
ValueError at read time, often in production first. Mitigation: treat enum case changes as schema changes requiring a backfill migration and a data audit query.Ramp-up. Low technical ramp — a Laravel developer familiar with enums is productive in under a day, and the package's concepts are a subset of the framework's. The real ramp cost is organizational: the team must learn the house convention (which cast, which validation rule, how labels are exposed) rather than the package API. Allocate half a day of documentation and one onboarding paragraph. Overall recommendation for a TPM: treat this as a convenience dependency with a mandatory build-vs-buy gate — approve only if the localization and generator features are concrete, near-term requirements that native Laravel does not cover; otherwise implement the small delta internally behind a project-owned interface and keep the framework upgrade path unblocked.
How can I help you explore Laravel packages today?