NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages
Enums for Laravel

Installation

Require the package with Composer:

composer require roundly-consulting/enums-for-laravel

That’s the whole setup. Enums for Laravel is a trait-only package: it ships no service provider, config file, migrations, views or Artisan commands, so there’s nothing to publish, migrate or register. There’s no facade either: the helpers live on your own enums, so there’s no stateful API to route through one. The code lives in three places:

  • RoundlyConsulting\Enums\Helpers — the trait you add to your enums.
  • RoundlyConsulting\Enums\DataTransferObjects\EnumOption — the value/label/name DTO returned by options().
  • RoundlyConsulting\Enums\Exceptions\EnumException — thrown by fromName() and fromLabel() when no case matches.

Generate an enum

Laravel’s own make:enum command scaffolds the enum — pass --string or --int for a backed enum. It lands in app/Enums when that directory exists:

php artisan make:enum NewsCategory --string

Then add the trait, as shown in Quick start.

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.