yokai/enum-bundle
Yokai Enum Bundle adds practical PHP 8.1 enum support: register enum types, expose choices in forms, validate values, and convert between enums, scalars, and database values through configurable services.
What the package actually is. Despite the "Laravel/PHP package" framing, yokai/enum-bundle is a Symfony bundle, not a framework-agnostic library. Its value is a class-based enumeration system (an abstract enum type, a manager/handler that resolves enum definitions, code-generation commands) wrapped in Symfony-specific glue: a DI extension and compiler pass, a Symfony Form type, a Validator constraint, a Twig extension, and a Doctrine DBAL custom type. That split matters for the evaluation: only a minority of the code is portable to Laravel, and that minority duplicates a language feature.
Architecture fit — weak. Laravel has no Bundle, DI-extension, or compiler-pass concept. Anything that depends on symfony/framework-bundle, symfony/form, symfony/validator, or Twig is dead weight in a Laravel service provider. More fundamentally, Laravel 10/11 require PHP 8.1+, which ships native backed enums. The package's core proposition — emulating enums with classes plus metadata — is largely redundant on the target runtime, and where it adds value (labels, option lists, DBAL mapping) that is 100–300 lines of in-house code, not a dependency.
Integration feasibility — low, with one narrow exception. The only component plausibly reusable outside Symfony is the Doctrine DBAL type, and only if the application already runs Doctrine ORM inside Laravel (uncommon; most teams use Eloquent). Attempting to install the bundle wholesale will pull Symfony Form/Validator/FrameworkBundle into a stack that does not use them: no fatal conflict, but unused surface area, an extra upgrade axis, and a misleading dependency graph for future maintainers.
Technical risk — moderate, driven by adoption, not code quality. MIT license, small codebase, and a recent release (2025-09-02) mean the code is inspectable and forkable. The risk is ecosystem signal: 12 stars, 0 dependents, no visible downstream usage. That implies a bus factor near 1, no published support/security policy, and no evidence of a BC policy across PHP, Symfony, and Doctrine DBAL major versions — the three axes most likely to break it. Attack surface is minimal (no network, no I/O, no deserialization), so security exposure is low; the real cost is upgrade tax.
Key questions to resolve before any commitment.
composer.json requirements, and is there a framework-agnostic core that can be consumed without framework-bundle?Bottom line. Score 0.21 with opportunity 25.19 is consistent with "reference implementation, not a dependency." Recommend do not adopt as a Laravel dependency; treat the repository as a design reference (or a bounded fork) if a specific capability is needed.
Stack fit, component by component. Map each Symfony-facing feature to its Laravel equivalent and reject the ones that don't translate:
| Package component | Laravel equivalent | Verdict |
|---|---|---|
Symfony Form EnumType |
Blade + Rule::enum() / in: validation |
Do not port |
Validator Enum constraint |
Custom validation rule wrapping a backed enum | Reimplement (~20 LOC) |
| Twig extension | Blade directive or enum label() method |
Reimplement |
| DI extension / compiler pass | Service provider + config, or nothing | Not applicable |
| Doctrine DBAL type | Eloquent $casts to a backed enum |
Reimplement |
| Enum base class + manager | Native enum ... : string implementing an internal interface |
Superseded |
Recommended implementation instead. Create a small internal convention in app/Support/Enums: native backed enums implementing a marker interface (e.g. HasLabel/HasOptions), a trait supplying label() and options(), an Eloquent cast, and a Rule::enum()-based validation rule. This mirrors the package's ergonomics at a fraction of the dependency cost, is idiomatic for new hires, and gives full IDE support.
Migration path, if enums already exist as class constants or arrays. (1) Inventory constant-holding classes and string-typed columns. (2) Convert one bounded context at a time to native backed enums, keeping persisted string values identical so no data migration is required. (3) Add the cast and validation rule alongside, not before. (4) Only after two contexts ship cleanly, retire the legacy pattern via static analysis (PHPStan/Rector rule) so the old style cannot creep back.
Compatibility constraints. Do not run both dialects simultaneously — if any part of the org has Symfony services using this bundle, keep them where they are and integrate across a data contract (the string value persisted in the shared database), never by sharing the library. For the DBAL type, confirm stored representations are plain scalars before assuming a drop-in swap; a mismatch means a backfill migration against production data, which should be scheduled and reversible.
Sequencing.
NOTICE preserving MIT attribution. Budget for ownership from day one.Maintenance. MIT and a compact codebase make a fork technically easy, which is exactly the trap: forking transfers the full upgrade burden in-house. Expect 2–5 engineer-days per year of baseline upkeep, plus a spike of several days each time PHP, Symfony, or Doctrine DBAL cuts a major. If adopted un-forked, you inherit the maintainer's release cadence with no contractual influence over it.
Support. GitHub issues only. No published SLA, security policy, or LTS commitment, and no commercial backing visible. Internal escalation path terminates at your own team; a P1 caused by an upstream bug has no vendor lever. Mitigation is architectural (isolate behind an internal interface) rather than procedural.
Scaling. Runtime cost is negligible: the code is stateless and CPU-cheap, and horizontal scaling is unaffected. The one thing to verify is registry construction — if the manager eagerly materializes all enum definitions on container boot, a large enum catalogue becomes per-request overhead on every worker; that is cacheable at build time, but confirm before assuming it is free.
Failure modes to instrument.
Ramp-up. A competent Laravel developer learns the API in half a day; the docs are Symfony-centric, so every example needs translation and the first real question lands on the adopting team. The larger cost is negative transfer: developers internalize a bespoke enum idiom that diverges from the language feature they will use everywhere else, degrading code-review quality and slowing onboarding for subsequent hires. By contrast, native backed enums carry zero ramp-up cost because they are already in the PHP manual and every IDE.
How can I help you explore Laravel packages today?