PHPackages                             vaened/php-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. vaened/php-enum

AbandonedLibrary

vaened/php-enum
===============

PHP enumeration support

V2.1.0(3y ago)12201MITPHPPHP ^8.0

Since Jul 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/vaened/php-enum)[ Packagist](https://packagist.org/packages/vaened/php-enum)[ RSS](/packages/vaened-php-enum/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (2)Dependencies (2)Versions (5)Used By (1)

PHP Enum
========

[](#php-enum)

[![Build Status](https://camo.githubusercontent.com/b1861118a2ac46aeb68aca9f4a751bc78b94387438f259641d31e4410e971a06/68747470733a2f2f7472617669732d63692e6f72672f7661656e65642f7068702d656e756d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vaened/php-enum) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/1a4ca0702d6b251ceb654ea932d36b3f245c30863e9e577b8ff75e4c1b841f7f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7661656e65642f7068702d656e756d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/vaened/php-enum/?branch=master) [![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Friendly enumeration implementation.

```
$status = Status::WARNING();

$status->key(); // WARNING
$status->value(); // Advertencia

// custom attribute
$status->getColor(); // yellow
```

Installation
------------

[](#installation)

PHP Enum requires PHP 8.

To get the latest version, simply require the project using Composer:

```
$ composer require vaened/php-enum
```

Declaration
-----------

[](#declaration)

To create an enumeration it is necessary to extend from [`Vaened\Enum\Enum`](https://github.com/vaened/php-enum/blob/master/src/Enum.php), in addition to creating constants for each value of the enumeration. This library has the ability to add attributes for each enumeration, very similar to the enumerations in java.

```
