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

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

vladdesv/simple-enum
====================

Dead simple enum

1.2.0(5y ago)018MITPHPPHP &gt;=5.3

Since Aug 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/vladdeSV/simple-enum)[ Packagist](https://packagist.org/packages/vladdesv/simple-enum)[ Docs](https://github.com/vladdeSV/simple-enum)[ RSS](/packages/vladdesv-simple-enum/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

[![SimpleEnum](header.svg)](header.svg)

SimpleEnum
==========

[](#simpleenum)

[![dead simple](https://camo.githubusercontent.com/08bb73e49842ef93caf0bd9b7476a5c9603fc81e1c17a67cdf7a8c5695284693/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646561642d73696d706c652d677261793f6c6162656c436f6c6f723d313131)](https://github.com/vladdeSV/simple-enum#example)[![minimum php version](https://camo.githubusercontent.com/def52338c237598d09802d0c9e7e9073440f357c190fd40cddeb81b862c7bbb4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f766c6164646573762f73696d706c652d656e756d3f636f6c6f723d383839324246266c6f676f3d706870266c6162656c436f6c6f723d323432393245)](https://github.com/vladdeSV/simple-enum/blob/master/composer.json#L25)[![master](https://github.com/vladdeSV/simple-enum/workflows/master/badge.svg)](https://github.com/vladdeSV/simple-enum/actions?query=workflow%3Amaster)

Dead simple PHP enum. This thing runs on PHP 5.3, heck maybe even PHP 5.1.2\*, so just yoink the files if you need it for your Legacy project.

\* This enum uses the Reflection class, which was introduced in PHP 5.1.2

Why?
----

[](#why)

I come from C-like languages with proper enums. Why is there no such simple, built-in, proper, enum in PHP?

The [SplEnum](https://www.php.net/manual/en/class.splenum.php) looks promising, but has some oddities with its implementation. As an added bonus, it might not work for [your setup](https://stackoverflow.com/a/57885080).

Other third-party alternatives (see [this](https://github.com/spatie/enum), [this](https://github.com/myclabs/php-enum), [this](https://github.com/DASPRiD/Enum), and [this](https://github.com/marc-mabe/php-enum) for instance) are overly complicated for my needs. This should probably solve it for most of my use cases.

Example
-------

[](#example)

```
