greg0ire/enum
A lightweight PHP enumeration library that lets you define enum-like classes with constants, validate values, and access available constants. It provides a simple AbstractEnum base class for projects that need typed, reusable sets of values without heavy dependencies.
Architecture fit. greg0ire/enum is a pre-PHP 8.1 workaround that emulates enum semantics using class constants plus validation helpers. It fits only in the narrow band of applications still running PHP 7.x or early PHP 8.0, typically Laravel 5.8–8.x. On any modern Laravel baseline (9.x on PHP 8.0+, 10.x/11.x on PHP 8.1+), the package is functionally redundant: native enum types, backed enums, and enum_exists() supersede it entirely. Treat it as a legacy compatibility shim, not a strategic dependency.
Integration feasibility. Technically low-effort. It is a Composer library with a minimal API surface (no service provider, no framework coupling), so adoption is a one-line require plus refactoring call sites to use its base class/validation helpers. There is no first-party Laravel integration to evaluate, and no facade, config, or migrations. The main integration work is not wiring but governance: deciding where enum semantics live and preventing new adoption once the codebase moves to PHP 8.1+.
Technical risk. The dominant risks are lifecycle and provenance, not runtime behavior:
Key questions.
Stack fit. Acceptable only for legacy PHP 7.x / Laravel ≤8 services. Reject for greenfield or any service on PHP 8.1+, where native enums should be mandated.
Migration path. Run a two-step program rather than a direct adoption:
App\Support\Enum) so call sites do not reference the third-party class directly. This is the critical step for reversibility.from()/tryFrom() for validation and mapping persisted scalar values via a serialization adapter.Keep the dependency pinned to an exact version and vendored (or mirrored) if license review permits, so an upstream disappearance does not break builds.
Compatibility. Verify Composer constraints against the target PHP minor and test against the oldest supported Laravel in the fleet. Because the package touches class-constant patterns, check autoloader behavior under optimized/classmap-authoritative autoloading, and validate that enum values survive json_encode, queue serialization, and Eloquent casting without change.
Sequencing. Legal review → upstream provenance audit → contain behind interface → native enum conversion per service → dependency removal. Do not convert and remove in the same release; keep one rollback-capable step between persistence changes and dependency deletion.
Maintenance. Near-zero upstream maintenance expected. The real burden is internal: the abstraction layer and conversion program must be staffed. Budget explicitly; an unmaintained shim tends to linger for years if not scheduled.
Support. No vendor support and a small community. Escalation path is "read the source" — acceptable only because the source is tiny. Plan for internal ownership of any fork.
Scaling. Runtime cost is negligible: class constants and validation are effectively free versus native enums. No memory, throughput, or infrastructure implications. This package is not a scalability concern in any dimension.
Failure modes.
Ramp-up. Engineers can learn the package's API in under an hour; it is small and idiomatic. The non-trivial ramp-up is organizational — aligning teams on the native-enum standard, reviewing call sites, and validating persisted data. Plan for a short technical onboarding and a longer governance runway.
How can I help you explore Laravel packages today?