Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Enum Laravel Package

cerbero/enum

A powerful enum implementation for Laravel that turns class constants into rich, type-safe enum objects. It adds validation rules, localization, Eloquent casting, comparisons, and Blade helpers while keeping enums simple and extensible.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Ship enum-heavy features faster. Status fields, order states, roles/permissions, notification types, feature flags—any feature where a fixed set of values drives behavior—becomes less boilerplate. This package collapses the helper methods (labels, options, casting, validation, JSON) that otherwise get hand-written in every enum class.
  • Build vs. buy (adopt) decision. The recurring "build" alternative is an internal App\Enums\BaseEnum trait with toArray(), labels(), forSelect(), etc. This package is that trait, already written, tested, and zero-dependency (MIT). Default to adopting it instead of building a homegrown helper class.
  • Standardization roadmap item. If teams are inconsistent today—some enums use attributes, some use methods, some leak raw values into Blade/API responses—this package gives a single convention for serialization, labels, and comparisons. Useful as a "one way to do enums" standard.
  • Direct use cases it enables: form select options (forSelect), localization-ready labels via attributes, Eloquent casts for DB persistence, request validation rules, toJson/toArray serialization for APIs, flag/bitmask combinations for permissions or settings, and case comparison (is(), in()) to replace brittle === checks scattered through services.
  • Roadmap enabler for PHP 8.1+ migration. Teams stuck mid-migration can treat native enums as the target; having ergonomic helpers removes one more reason to keep legacy constant classes around.

When to Consider This Package

Adopt when:

  • The codebase is on PHP 8.1+ and you already use (or plan to use) native enums, especially in a Laravel app where enum values cross model → validation → view/API boundaries.
  • Developers are repeatedly writing the same enum helpers, or you're seeing drift in how enums are serialized and displayed.
  • You want labels/metadata attached to enum cases without a separate lookup table or config file.
  • You want validation and Eloquent casting with enums without extra glue code.
  • Zero-dependency, MIT, small-surface-area utilities fit your dependency policy (favorable: low blast radius, easy to vendor or fork).

Look elsewhere or defer when:

  • The project is below PHP 8.1 or doesn't use enums at all.
  • You already standardized on a comparable solution (e.g., an established internal base enum or another enum library) and the migration cost outweighs the cleanup.
  • Values must be dynamic/database-driven rather than compile-time cases—this is native enum territory, not this package.
  • Maintenance risk matters more than convenience: single maintainer, ~360 stars, low dependent counts. Mitigate before committing broadly; the code is simple and zero-dependency, so fork/vendor is viable, but don't let it become a load-bearing dependency without a fallback plan.
  • Your team prefers framework-native features only (Laravel's built-in enum casts and Rule::enum may cover part of the need).

How to Pitch It (Stakeholders)

For executives: This is a free, MIT-licensed utility that removes repetitive code when using PHP's built-in enum feature. It reduces developer time on a common class of features (statuses, categories, permissions) and standardizes how those values are displayed, validated, and stored. Cost is near zero; risk is low because it has no runtime dependencies and can be removed or forked with minimal effort if needed.

For engineering: It layers practical helpers on native enums—labels via attributes, forSelect/toArray/toJson for output, Eloquent casts and validation rules for persistence and input, and is()/in() for comparisons/flags. Zero dependencies keeps the install surface clean; small API means low learning cost. Recommendation: pilot on one or two enum-heavy features first, capture how much helper code it deletes, then decide whether to adopt it as the team's standard. Flag single-maintainer/bus-factor risk and set a simple rule: keep our enum definitions portable (no framework-specific magic in domain code) so the package stays a convenience, not a lock-in.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle