Download the PHP package vixen/laravel-enums without Composer

On this page you can find all versions of the php package vixen/laravel-enums. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-enums

Laravel Enums

A collection of composable traits and attributes for working with PHP backed enums in Laravel.

Requirements

Installation

Usage

Add any combination of traits to your backed enum:

Traits

HasLabels

Provides label functionality using #[Label], #[LongLabel], and #[ShortLabel] attributes.

When no attribute is provided, a label is auto-generated from the case name:

Label type parameter

Instead of separate attributes, you can use the type parameter on #[Label]:

Fallback chain

When requesting a specific label type (e.g., longLabel()), the resolution order is:

  1. The exact attribute (#[LongLabel] or #[Label(..., type: 'long')])
  2. The default #[Label]
  3. Auto-generated label from the case name

Translation support

#[Label] and #[LongLabel] values are passed through Laravel's __() helper, so you can use translation keys:

#[ShortLabel] returns the raw string without translation, since it's intended for abbreviations.

HasDescriptions

Provides description functionality using the #[Description] attribute. Useful for longer descriptive text alongside labels.

Returns null when no #[Description] attribute is present on a case.

Translation support

#[Description] values are passed through Laravel's __() helper, so you can use translation keys:

HasOptions

Returns label-value pairs as a Collection, useful for select dropdowns and form components. Requires the enum to provide a label() method (typically via HasLabels) and a description() method (typically via HasDescriptions).

Customizing fields with only

Both options() and descriptiveOptions() accept an optional only parameter to customize which fields appear in the returned arrays. The value field is always included.

Available fields: value, name, label, shortLabel, longLabel, description. An InvalidArgumentException is thrown for fields that don't exist on the enum.

HasValues

Returns a Collection of all backed values.

Filterable

Select or exclude specific cases by name. Returns an EnumCollection (see below), so you can chain toOptions() or toDescriptiveOptions() directly.

EnumCollection

A custom collection class extending Laravel's Collection, designed to hold enum cases and provide convenient conversion methods.

toOptions() requires the enum to use HasLabels. toDescriptiveOptions() additionally requires HasDescriptions. Both methods accept an optional only parameter — see HasOptions for details.

Returned automatically by Filterable::only() and Filterable::except().

Snakeable

Converts the case name to snake_case.

ToArray

Converts a single case to an associative array. Requires the enum to provide a label() method.

ToValue

Explicit accessor for the backed value.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-enums with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/support Version ^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vixen/laravel-enums contains the following files

Loading the files please wait ...