paillechat/php-enum
PHP 7+ enum library: define enums by extending Enum and declaring constants, then instantiate via static named calls (IssueType::ONE()). Instances are strict-equal singletons, work with in_array/type hints, and can convert to/from names.
UserRole::ADMIN, OrderStatus::PENDING), reducing runtime errors and improving IDE autocompletion.OrderStatus::PENDING to "pending" for APIs or database storage) via createByName().myclabs/php-enum (more stars, recent updates)."active" → Status::ACTIVE).For Executives:
"This package lets us enforce strict, self-documenting constants (e.g., PaymentStatus::PENDING) across our Laravel app, reducing bugs from magic strings. It’s a lightweight, MIT-licensed solution that works today—with minimal effort to upgrade to PHP 8.1’s native enums later. Think of it as ‘type safety on steroids’ for our domain logic, with zero operational overhead."
For Engineers: *"We’re adding a dependency that:
UserRole::ADMIN instead of 'admin').createByName().For Developers: *"This lets you:
Status:: → shows PENDING, APPROVED).$status === Status::PENDING works out of the box.Status::createByName('PENDING') for APIs.
Example:// Before: if ($status == 'pending') { ... } // 🚨 Magic string!
// After: if ($status === Status::PENDING) { ... } // ✅ Type-safe!
```*
*Tradeoff*: Not PHP 8.1’s native enums, but it’s a drop-in replacement for now."*
How can I help you explore Laravel packages today?