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

Php Enum Utils Laravel Package

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.

Deep Wiki
Context7

Product Decisions This Supports

  • Feature scoping and delivery speed. The package is thin glue over native PHP 8.1+ enums (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.
  • Build vs. buy: buy (adopt), not build. Writing these helpers in-house costs half a day plus maintenance; adopting a small MIT package with a narrow public surface is cheaper than owning it. Reserve "build" only if you need enum metadata, labels/i18n, or DB-backed dynamic enums — none of which this package covers.
  • Roadmap items this typically unblocks or de-risks:
    • Form dropdowns and filter UIs generated from a single source of truth (no more hand-maintained arrays drifting from the enum).
    • API request validation for enum-backed fields (status, type, region, channel) without per-controller custom rules.
    • Status/state-machine features (order lifecycle, approval flows, subscription states) where names and values must stay in sync across UI, validation, and persistence.
    • Test fixtures, seeders, and factories that enumerate valid values.
  • Architecture / platform decisions. It's a reasonable "standardize on this" candidate for a monolith or multi-service codebase, because the alternative — each team inventing its own BaseEnum trait — is where inconsistencies in API contracts creep in.
  • Explicitly NOT a driver for: pricing, packaging, or customer-facing differentiation. Treat it as developer-productivity infrastructure, evaluated on reduced defect rate and onboarding cost, not on user-visible value.

When to Consider This Package

Adopt when:

  • You're on PHP 8.1+ and use native backed enums, and the codebase has more than a handful of them.
  • Enums already surface in multiple layers (HTTP validation, form selects, API resources, seeders) and you're seeing duplication or drift.
  • You're on Laravel and want a first-party-feeling validation rule rather than writing a Rule object per enum.
  • You value a small, pin-able dependency over a framework-blessed abstraction — the blast radius of a breaking change here is low because the API is shallow and easily vendored.
  • You want consistency across teams without publishing an internal package and owning its release cadence.

Look elsewhere or skip when:

  • You have one or two enums, or a single codebase-wide BaseEnum that already works — the savings don't justify a new dependency entry in composer.json.
  • Maturity signals matter to you. ~31 stars and an unspecified/single-maintainer upstream (the repository field is not even resolvable in this record) means low bus factor and no community pressure-testing. If your org requires active maintenance guarantees or a support SLA, this fails that bar.
  • You need labels, translations, descriptions, icons, or arbitrary enum metadata — that's a different package class (e.g., attribute-driven enum metadata libraries or UI-layer enum helpers).
  • You need database-backed / admin-editable enums (statuses that non-engineers can add at runtime). This package is compile-time only.
  • You're in a strict domain layer that forbids framework coupling — the Laravel validation rule pulls the package toward your HTTP boundary; keep it out of the domain if that's a hard rule.
  • Your team already standardizes on a broader toolbox (e.g., a Laravel support package) that covers the same ground; adding a second source of truth is worse than either alone.

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.

How to Pitch It (Stakeholders)

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.

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.
ably/pubsub-server
mstfkhazaal/defender
mfonte/base62x
karnoweb/metapilot
tobya/bcsapiwrapper
swalker2/cpanel
vish4395/laravel-translation-manager
morningtrain/economic
teksite/systeminfo-laravel
atomcms/voting
run6/weather
siokas/laravelembeddirectives
adamlien/pkuuids
gilsonsouza/lara-doc-generator
manelgavalda/enrollment_mobile
unabomber/timezone
delatbabel/contacts
astritzeqiri/g-recaptcha
kevinongko/laravel-genode
developeruz/laravel-analytics