vicgutt/php-enhanced-enum
A PHP package that enhances native enums with extra helpers and conveniences, making them easier to work with in Laravel and plain PHP projects alike.
What the package actually is. vicgutt/php-enhanced-enum is a thin convenience layer over PHP 8.1 native enums — a trait (or small helper set) that adds ergonomics such as case listing, value/label maps, comparison helpers, and array/option conversion. It is pure PHP, MIT-licensed, has no framework coupling, and adds no runtime services. The technical surface area is small; the risk is not technical, it is lifecycle.
Architecture fit. Good in principle. Native enums are already the correct domain-modeling primitive in PHP 8.1+, and a helper trait slots in without dictating application structure. It is additive, not a replacement for enum semantics, so it does not create lock-in at the architecture layer. If the team is not already using native enums consistently, this package does not solve that problem — it decorates it.
Integration feasibility. Trivial mechanically: composer require, one use statement per enum, no migrations, no config publishing, no service provider expected. A spike is measured in hours. The cost is not in wiring it up, it is in deciding whether to own it.
Technical risk — high, and lifecycle-driven rather than defect-driven.
Key questions to resolve before any commitment.
php and illuminate/* constraints, and do they resolve against our target PHP/Laravel versions?tryFrom/invalid values?__call? Magic methods would complicate static analysis.values(), labels(), toArray(), options()), and do they collide with BenSampo/laravel-enum, spatie/laravel-enum, or our own conventions?toArray()/jsonSerialize() output shape leak into API contracts?Stack fit. Technically clean for any PHP 8.1+ codebase, Laravel or otherwise. No runtime footprint, no bootstrap cost, no PSR conflicts. The only real fit question is version-constraint fit, not architectural fit.
Migration path. Do not rip-and-replace existing constants or string columns. Introduce per enum, starting with one bounded domain (e.g., order status) where the enum already exists or is being introduced anyway. Keep persistence encoding unchanged — store ->value, not the enum object, and validate the serialization boundary explicitly before rollout.
Compatibility. Two concrete hazards: (a) Composer constraint resolution may fail on current Laravel majors given the 2022 vintage — verify with composer why-not against our actual lockfile, not against docs; (b) overlapping helper packages. If any other enum package is present, audit method-name overlap before installing both. Also confirm static-analysis stubs exist if we run Larastan at a meaningful level.
Sequencing.
App\Support\Enums under the MIT license and own it. This gets the ergonomics with zero external dependency and eliminates the abandonment failure mode entirely.Maintenance. Effectively self-maintained. There is no realistic expectation of upstream fixes for PHP 8.4 deprecations or Laravel 12 constraint updates. Budget an internal owner and roughly a few hours per PHP/Laravel major upgrade if forked; if taken as a dependency, the same hours appear as unplanned breakage instead.
Support. No SLA, no issue triage, no security advisories. That is acceptable for a 100-line trait and unacceptable for a dependency we cannot patch. This is the strongest argument for vendoring the code rather than requiring it.
Scaling. Negligible. No services, no persistence, no per-request overhead beyond normal method calls. Nothing here affects throughput, infrastructure, or cost. The operational weight sits entirely in governance, not runtime.
Failure modes to plan for.
toArray()-style helpers are wired into API responses; payload shape becomes coupled to a third-party package's implementation.Ramp-up. Low for engineers — one afternoon of reading and a handful of examples. The real ramp-up cost is organizational: establishing the convention, assigning an owner, and deciding the fork policy. That cost exceeds the engineering cost of the package by an order of magnitude at this adoption level.
TPM recommendation. Do not adopt as a production dependency. Use it as a reference implementation: read the source, copy the relevant helpers into an internally owned trait, and credit the MIT license. The functionality is worth having; the dependency is not. Reassess only if the package shows renewed releases, test coverage, and non-zero dependents.
How can I help you explore Laravel packages today?