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

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

rexlabs/enum
============

Enumeration (enum) implementation for PHP

2.4.0(1y ago)48482.2k↓14.7%52MITPHPPHP &gt;=7.0 &lt;8.5CI failing

Since Mar 6Pushed 1y ago5 watchersCompare

[ Source](https://github.com/rexlabsio/enum-php)[ Packagist](https://packagist.org/packages/rexlabs/enum)[ RSS](/packages/rexlabs-enum/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (1)Versions (16)Used By (2)

Deprecated
==========

[](#deprecated)

> **Warning**If you are using PHP 8.1 or higher, we recommend you use [native php enums](https://www.php.net/manual/en/language.enumerations.examples.php) in place of this package.
>
> We may release some maintenance patches but support for this package is otherwise being discontinued.
>
> Feel free to fork our code and adapt it to your needs.

Enum PHP Library
================

[](#enum-php-library)

[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://opensource.org/licenses/MIT)[![Packagist](https://camo.githubusercontent.com/1aa90f653f1259a9bf484adc03a19ec0f925d18c41118f8ea9f21b5299676295/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7265786c6162732f656e756d2e737667)](https://packagist.org/packages/rexlabs/enum)

Overview
--------

[](#overview)

This library provides an Enum / Enumeration implementation for PHP.

Why use this library
--------------------

[](#why-use-this-library)

- Very simple to implement and use.
- Complex can optionally be mapped by providing a `map()` method.
- Allows type-hinting when passing enumerated values between methods and classes.

Usage
-----

[](#usage)

First create a new class that extends `\Rexlabs\Enum\Enum` and do the following;

1. Declare your constants
2. *Optional*: provide a `map()` method:

Example
-------

[](#example)

```
