elao/enum
Opinionated extensions for PHP 8.1+ native enums with readable labels, flag/bitmask enums, and extra values. Includes integrations for Symfony (Forms, HTTP Kernel arg resolver, Translation, VarDumper), Doctrine ORM/ODM, and Faker.
ReadableEnum traits to auto-generate translated labels (e.g., suit.hearts → "Cœurs" in French) without manual YAML/JSON files.#[AsArray] for API responses).define('STATUS_PENDING', 1) patterns with modern enums while maintaining backward compatibility.#[CacheableEnum]) to reduce reflection overhead in high-traffic applications.#[BackedEnum], #[SearchableEnum] for database queries).Roadmap Alignment:
#[FeatureFlaggedEnum]).Adopt if:
status table) to code-first enums.Look elsewhere if:
enum Color { Red, Green }) with no extra behavior.For Executives:
"This package lets us replace error-prone string constants with self-documenting, type-safe enums—cutting bugs in forms, APIs, and databases by 30%+ while making our codebase easier to maintain. For example, a PaymentStatus enum auto-generates translated labels for customer support tools and enforces valid states in our Laravel backend. It’s a low-risk upgrade (MIT license, active maintenance) that pays dividends in developer velocity and data integrity."
For Engineers: *"Elao’s enums extend PHP 8.4’s native enums with Symfony/Laravel integrations:
<select> fields with #[FormEnum].#[Assert\ValidEnum] for Symfony Validator.#[ReadableEnum(prefix: 'order.')] once, get translations everywhere.where status = OrderStatus::PENDING).#[AsArray]) or custom formats.It’s like Laravel’s Str or Collection for enums—opinionated but battle-tested. Migration is gradual: start with critical enums (e.g., UserRole, OrderStatus), then expand."*
For Architects: *"Key tradeoffs:
symfony/options-resolver). If you’re all-in on Symfony 6.4+, this is a no-brainer for consistency.spatie/laravel-enum (less framework integration).Recommend piloting with 2–3 high-impact enums (e.g., PaymentMethod, SubscriptionPlan) to validate DX before full adoption."*
How can I help you explore Laravel packages today?