Enums vs final class constants: which to use
PHP 8.1 enums are a proper language feature but they have constraints. Final classes with constants work everywhere and have fewer restrictions.
When do you choose one over the other?
If the set of values is fixed and known at compile time, and you want type safety (function signatures accepting StatusEnum not string), use Enums. If the values are dynamic or loaded from config, use constants or a plain class.
Backed enums (string, int) work well for DB storage and serialization. Pure enums (no backing type) are good for state machines where the label matters, not an underlying value.
Enum methods are a nice feature: you can add label(), color(), or isActive() methods directly on the enum. That logic used to live in a helper class or a match expression repeated throughout the code.
Enums cannot be extended. If you need a hierarchy of related statuses or want to add a value in a child context, a final class with typed constants gives more flexibility.
Eloquent casting to enum types is built-in since Laravel 9. The DB value is automatically converted to the enum case on read. Makes models much cleaner.
ORM compatibility was the main friction point early on. Doctrine needed custom types, Eloquent casts, ActiveRecord frameworks varied. Most have good enum support now.
```php blocks are runnable.