The original post: /r/php by /u/cerbero90 on 2025-01-18 10:38:32.

Laravel Enum is a package designed for Laravel that enhances the capabilities of native PHP enums.

It includes all the features from its framework-agnostic counterpart, including:

  • comparing names and values
  • adding metadata to cases
  • hydrating cases from names, values, or meta
  • fluently collecting, filtering, sorting, and transforming cases

And it provides Laravel-specific functionalities:

  • autowiring meta to resolve classes through the Laravel IoC container
  • castable cases collection for Eloquent models
  • magic translations
  • encapsulation of Laravel cache and session keys
  • Artisan commands that:
    • annotate enums for IDE autocompletion of dynamic methods
    • create annotated enums, both pure and backed, with manual or automatic values
    • convert enums to TypeScript for backend-frontend synchronization
  • and much more!

https://github.com/cerbero90/laravel-enum