Download the PHP package laravel-enso/enums without Composer
On this page you can find all versions of the php package laravel-enso/enums. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laravel-enso/enums
More information about laravel-enso/enums
Files in laravel-enso/enums
Package enums
Short Description Enums for Laravel Enso
License MIT
Homepage https://github.com/laravel-enso/enums
Informations about the package enums
Enums
Description
Enums provides both legacy class-based enumerations and frontend-ready native PHP enum discovery for Laravel Enso.
The package keeps backwards compatibility with Enso's original enum classes while also scanning vendor and application Enums folders for native PHP enums that implement specific contracts. Those enums can then be registered into application state and exposed to the frontend in a normalized shape.
It is used throughout the Enso ecosystem for typed option lists, shared UI state, and enum mapping between backend code and frontend consumers.
::: warning Note Since PHP now provides native enums, we strongly recommend migrating new and existing code to native PHP enums wherever possible.
We still intend to keep supporting the Enso enum registry layer for ecosystem integration and frontend state registration, even as the legacy custom enum implementation is phased out. :::
Installation
Install the package:
The package auto-registers:
LaravelEnso\Enums\AppServiceProviderLaravelEnso\Enums\EnumServiceProvider
If you want to customize which vendor namespaces are scanned, publish the configuration:
If you want an application provider for registering legacy enums explicitly, publish the stub:
Default configuration:
For native frontend enums, place enum classes under your PSR-4 Enums folder. In a standard Laravel application this means app/Enums.
Features
- Provides a base class for legacy class-based enums.
- Supports native PHP enums for frontend/state registration.
- Scans configured vendor packages and the host application for enum classes.
- Registers enum state under a single
enumsstore payload. - Exposes a facade for registering and removing legacy enums.
- Supports optional enum mapping through a dedicated
Mappablecontract. - Includes helper traits for select lists, searching, and random case selection.
Usage
Legacy Class-Based Enums
Extend LaravelEnso\Enums\Services\Enum:
Available helpers:
Native PHP Enums For Frontend State
Implement LaravelEnso\Enums\Contracts\Frontend on a backed enum:
The enum will be discovered from an Enums folder and registered under the key returned by registerBy().
Legacy Enum Registration
Register legacy enums through the facade or EnumServiceProvider:
API
Configuration
config/enums.php
Keys:
vendors
The scanner checks:
vendor/<configured-vendor>/*- the application base path and its PSR-4 root
Service Providers
LaravelEnso\Enums\AppServiceProviderLaravelEnso\Enums\EnumServiceProvider
Responsibilities:
- merge and publish config
- publish the legacy enum provider stub
- register legacy enums listed in the provider's
$registerproperty
Legacy Enum Base Class
LaravelEnso\Enums\Services\Enum
Key methods:
constants(): arrayget($key)has($key): boolkeys()values()json(): stringarray(): arrayall(): arrayobject(): objectcollection()select()localisation(bool $state = true): void
Native Enum Discovery
LaravelEnso\Enums\Services\SourceLaravelEnso\Enums\Services\Enums
Requirements for discovery:
- enum must exist in an
Enumsfolder - enum must implement
LaravelEnso\Enums\Contracts\Frontend
Optional mapping:
- implement
LaravelEnso\Enums\Contracts\Mappable
Legacy Enum Registry
LaravelEnso\Enums\Services\LegacyEnumsLaravelEnso\Enums\Facades\Enums
Key methods:
register($enums)remove($aliases)all(): array
State Provider
LaravelEnso\Enums\State\Enums
Provides merged enum state for frontend consumption under the enums store key.
Traits
LaravelEnso\Enums\Traits\SelectLaravelEnso\Enums\Traits\SearchLaravelEnso\Enums\Traits\Random
Depends On
Required Enso packages:
Framework dependency:
Companion frontend package:
Contributions
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!
All versions of enums with dependencies
laravel-enso/helpers Version ^4.0
laravel/framework Version ^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
php Version ^8.0