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
Laravel Enumeration

Laravel Enumeration Laravel Package

sourceboat/laravel-enumeration

A Laravel package for defining and using enumerations in PHP, with support for validation rules, model casting, and comparing enum values in a clean, type-safe way across your application.

View on GitHub
Deep Wiki
Context7

Simple, extensible and powerful enumeration implementation for Laravel, based on eloquent/enumeration.

Frequently asked questions about Laravel Enumeration
How do I install sourceboat/laravel-enumeration in a Laravel application?
Install it with Composer using composer require sourceboat/laravel-enumeration. The package ships a service provider that Laravel's package auto-discovery registers, so no manual registration is normally needed. After that you define your enum classes by extending the package's base enum type. Before installing, check the composer.json constraints to confirm your PHP and Laravel versions are supported.
Which PHP and Laravel versions does laravel-enumeration support?
The supported version matrix cannot be assumed from the repository metadata alone. Read the package composer.json for its php, laravel/framework, and illuminate/* constraints, and check whether the pinned eloquent/enumeration dependency allows your stack. Look for CI evidence that the advertised matrix actually passes. Running composer why-not with your target versions is the fastest way to confirm compatibility.
Can I use laravel-enumeration for Eloquent model casting?
Yes, the package provides Eloquent attribute casting so model attributes are returned as enum instances instead of raw strings or integers. You assign the cast in the model's casts array the same way you would any custom cast. Note that on Laravel 9 and later, native enum casting already does this, so avoid mixing both approaches in one model. Always verify the cast behaves correctly on null values and on database rows with unexpected values.
How does laravel-enumeration compare to PHP 8.1 native backed enums?
PHP 8.1 backed enums, combined with Laravel's first-class enum casting and the Enum validation rule, cover most of what this package provides. The package adds Laravel conventions such as a service provider, enum base classes, validation rule integration, and label or translation helpers. On a PHP 8.1+ stack it is largely additional dependency surface for convenience. On PHP 7.x or 8.0, where native enums do not exist, it fills a real gap.
Is sourceboat/laravel-enumeration actively maintained?
The available metadata is a warning sign: zero stars, zero dependents, and no visible community traction, which is consistent with an unpublished, internal, forked, or abandoned package. Before adopting it, check the last commit date, release cadence, open issues, and license. Assume no external bug-fix throughput or security response channel unless you can verify otherwise. If you adopt it, plan for a named internal owner and a fork-and-vendor path.
How do I validate an enum value in a Laravel form request with this package?
The package supplies an enum validation rule you add to your form request's rules array, so submitted values are checked against the enum's allowed members. This keeps validation logic next to the enum definition instead of duplicating a list of strings. On Laravel 9+ you can also use the built-in Enum rule, which may be preferable if you are already migrating to native enums. Confirm the exact rule class name and usage in the package documentation for your pinned version.
What is the difference between laravel-enumeration and eloquent/enumeration?
sourceboat/laravel-enumeration is a thin Laravel-oriented wrapper around eloquent/enumeration. It adds the framework conventions developers expect: package auto-discovery, enum base classes, Eloquent casting, validation rules, and typically label or translation helpers. The core enumeration behavior comes from the upstream package. Adopting it means owning two supply chains for what is essentially a convenience layer.
How do I compare enum values safely with laravel-enumeration?
The package provides comparison helpers so you compare enum instances rather than loose strings or integers, which avoids subtle bugs from typos or type juggling. Native backed enums also support strict identity comparison with the triple equals operator, so the package is not the only type-safe option. Prefer comparing against enum constants or instances consistently throughout the codebase. Avoid falling back to raw value comparison in Blade templates and query scopes.
Should I use laravel-enumeration in a new Laravel 10 or 11 project?
Generally no. On modern Laravel with PHP 8.1+, native backed enums plus built-in enum casting and the Enum validation rule deliver the same value without a third-party dependency. Wrapper packages that hook into Eloquent casting and the validation pipeline are sensitive to Laravel major-version internals, so an unmaintained wrapper can become an upgrade blocker. Only consider it if you have verified a maintained fork with clear internal ownership.
How do I test enums defined with laravel-enumeration, and what are the alternatives if it is abandoned?
Unit test enum helper methods directly with PHPUnit, then feature test that model casts return the expected enum instances and that the validation rule passes for valid values and fails for invalid ones. Include edge cases such as null attributes and legacy database values that no longer map to a case. If the package proves unmaintained, the alternatives are migrating to native backed enums or vendoring a fork you control. Either path is easier if your enums are kept small and free of framework-specific logic.
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.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager