PHPackages                             sypspace/laravel-enum - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sypspace/laravel-enum

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sypspace/laravel-enum
=====================

Enum generator for Laravel.

1.3.0(5y ago)0551MITPHPPHP ^7.1

Since Apr 19Pushed 4y agoCompare

[ Source](https://github.com/sypspace/laravel-enum)[ Packagist](https://packagist.org/packages/sypspace/laravel-enum)[ Docs](https://github.com/cerbero90/laravel-enum)[ GitHub Sponsors](https://github.com/cerbero90)[ RSS](/packages/sypspace-laravel-enum/feed)WikiDiscussions develop Synced 6d ago

READMEChangelogDependencies (6)Versions (8)Used By (0)

Laravel Enum
============

[](#laravel-enum)

[![Latest Version on Packagist](https://camo.githubusercontent.com/aa856141d7c2103860c9bd1c6a236fc19292dc2a02def98f7a68017c9a0f554c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6365726265726f2f6c61726176656c2d656e756d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cerbero/laravel-enum)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/6fa92a99393d084599fc8eb38f43998a4b9b1bd1dfe82904726a1beb7065ed31/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6365726265726f39302f6c61726176656c2d656e756d2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/cerbero90/laravel-enum)[![Coverage Status](https://camo.githubusercontent.com/2a1e893be466261be7468477ab6bdcae121b0f3392968fe6e51246637d8f86dd/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6365726265726f39302f6c61726176656c2d656e756d2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/cerbero90/laravel-enum/code-structure)[![Quality Score](https://camo.githubusercontent.com/ff2253b510b11c3369a5124283015898959202014de63b225c44eed8f2266503/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6365726265726f39302f6c61726176656c2d656e756d2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/cerbero90/laravel-enum)[![Total Downloads](https://camo.githubusercontent.com/b10880ee34184cc0bc7c962436f782f51d8d132d1fc885192f8a118ebdf757be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6365726265726f2f6c61726176656c2d656e756d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cerbero/laravel-enum)

Laravel package that introduces a new Artisan command to generate [Enum classes](https://github.com/rexlabsio/enum-php).

It provides an easy syntax to specify and map constants in Enum classes while adding PHPDoc tags to make IDEs recognise what constants can be invoked as methods to instantiate an Enum class.

Install
-------

[](#install)

Via Composer

```
$ composer require cerbero/laravel-enum
```

Usage
-----

[](#usage)

Enums can be generated by calling the Artisan command `make:enum` and specifying the class and constant names. Many enums can be defined at once by separating them with pipes (please note the use of quotes):

```
$ php artisan make:enum Status 'IN_PROGRESS|COMPLETE|FAILED'
```

In the previous example no key has been defined, in this case keys are assumed to be equal to their lowercased constant name. This is how the `Status` enum will look like:

```
