dive-be/php-enum-utils
Utilities for PHP 8.1+ enums in Laravel: convert enum cases to arrays, values, options, and labels for forms and APIs, compare and inspect cases, and cut boilerplate with a small, dependency-free helper set that makes working with native enums painless in everyday application code.
values(), names(), toArray(), toSelectArray(), fromName(), tryFromName(), plus a Laravel validation rule). It doesn't unlock new product capability — it removes the recurring 30-line boilerplate that otherwise gets re-written or copy-pasted in every enum-backed feature. That translates to fewer review cycles and less "convention drift" between squads.BaseEnum trait — is where inconsistencies in API contracts creep in.Adopt when:
Rule object per enum.Look elsewhere or skip when:
BaseEnum that already works — the savings don't justify a new dependency entry in composer.json.Adoption criteria I'd actually gate on: (1) license and dependency tree are clean (MIT, appears dependency-free), (2) the two or three methods you need pass a 15-minute spike against your existing enums, (3) pinned to an exact version with an owner assigned to track upgrades, (4) wrapped behind your own thin helper or trait so a future replacement is a one-file change.
To executives (30 seconds): This is a small, free, MIT-licensed utility that removes repetitive plumbing around PHP's native enum feature. It won't change what we ship, but it measurably reduces the class of bugs where a dropdown, an API validator, and a database column silently disagree about valid values — a recurring source of production incidents in status- and type-driven features. Cost is effectively zero; the realistic downside is that the library is young and lightly maintained, which we mitigate by pinning the version and keeping our usage behind a one-file wrapper so we can drop it in an afternoon.
To engineering leadership: Native enums are the right primitive, but PHP doesn't ship ergonomics for "list the values for a select box" or "validate this request field against the enum." Every team solves that differently. This package standardizes it in ~a day of integration work, gives us a proper Laravel validation rule, and eliminates copy-pasted BaseEnum traits. It's a shallow API with no meaningful dependency footprint, so vendor lock-in is near zero — we can fork or replace it if upstream goes quiet. Recommended action: adopt behind an internal trait, pin the version, and add it to the dependency-review list.
To the engineering team (the honest caveats): Low star count, unclear maintenance cadence, and a release date that needs verification against the tag you actually install. Do a quick spike against your real enums, confirm the toSelectArray/fromName/validation-rule behavior matches your conventions, and don't let it leak into the domain layer. If it doesn't fit in an hour, write the 40 lines yourself and move on — the decision is reversible either way.
How can I help you explore Laravel packages today?