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

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

konekt/enum
===========

SPL inspired PHP enum class implementation

4.2.1(2mo ago)212.3M↓24.6%220MITPHPPHP ^8.0CI passing

Since May 30Pushed 2mo ago6 watchersCompare

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

READMEChangelogDependencies (2)Versions (29)Used By (20)

Konekt Enum
===========

[](#konekt-enum)

[![Tests](https://camo.githubusercontent.com/d0e1c35d3c9679977af4b428ad8b0558dd2cd337deb3e7fe825f78210988b016/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6172746b6f6e656b742f656e756d2f74657374732e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/artkonekt/enum/actions?query=workflow%3Atests)[![Packagist Stable Version](https://camo.githubusercontent.com/7867ba7402c7ce549b6ab21eaf3929a64c46260a7b1bc3638f2300e4f72602b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6f6e656b742f656e756d2e7376673f7374796c653d666c61742d737175617265266c6162656c3d737461626c65)](https://packagist.org/packages/konekt/enum)[![Packagist downloads](https://camo.githubusercontent.com/c03326780e4b3886ab6b44ca7594d7ee3cfe4ab7e0fa405ff60a7f5c3c1eaef0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6f6e656b742f656e756d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/konekt/enum)[![StyleCI](https://camo.githubusercontent.com/5da9865802de8c180a46a7aa0be61eba73998787e107be17dbd6cbdd7fdca0e6/68747470733a2f2f7374796c6563692e696f2f7265706f732f36303033363530342f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/60036504)[![MIT Software License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

PHP Enum Class
--------------

[](#php-enum-class)

> Enums are handy when a variable (especially a method parameter) can only take one out of a small set of possible values.

Konekt Enum is a lightweight abstract class that enables creation of PHP enums.

> **Why not PHP 8.1 Enums?** This package was created back in 2013, and has been in use across many libraries. We're planning to find the way to make this package be based on native PHP enums AND keep compatibility with earlier versions as much as possible. This is expected in the **v5.0** release of this package.

### Usage

[](#usage)

Extend the base class and define constants on it:

##### Example

[](#example)

```
class ChessPiece extends \Konekt\Enum\Enum {
    const KING   = 'king';
    const QUEEN  = 'queen';
    const ROOK   = 'rook';
    const BISHOP = 'bishop';
    const KNIGHT = 'knight';
    const PAWN   = 'pawn';
}

var $queen = new ChessPiece('queen');
```

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

[](#installation)

using composer: `composer require konekt/enum`

Documentation
-------------

[](#documentation)

For detailed usage and examples go to the [Konekt Enum Documentation](https://konekt.dev/enum) or refer to the markdown files in the `docs/` folder of this repo.

For the list of changes read the [Changelog](Changelog.md).

Upgrade
-------

[](#upgrade)

- From 3.x -&gt; 4.x see [Upgrade to 4.0](https://konekt.dev/enum/4.x/upgrade#from-v3-to-v4)
- From 2.x -&gt; 3.x see [Upgrade to 3.0](https://konekt.dev/enum/4.x/upgrade#from-v2-to-v3)
- From 1.x -&gt; 2.x see [Upgrade to 2.0](https://konekt.dev/enum/4.x/upgrade#from-v1-to-v2)

Laravel Eloquent Integration
----------------------------

[](#laravel-eloquent-integration)

There is a tiny trait for Laravel that helps you to automatically map fields of Eloquent models to/from Enum objects. For more details go to the [konekt/enum-eloquent](https://github.com/artkonekt/enum-eloquent) package.

###  Health Score

65

—

FairBetter than 99% of packages

Maintenance86

Actively maintained with recent releases

Popularity50

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 93% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~134 days

Recently: every ~290 days

Total

28

Last Release

71d ago

Major Versions

1.2.x-dev → 2.0.02017-09-13

2.2.x-dev → 3.0.02019-06-24

2.3.0 → 3.0.x-dev2019-12-25

3.1.x-dev → 4.0.02022-03-10

PHP version history (5 changes)1.0.0PHP &gt;=5.5.9

2.0.0PHP &gt;=7.0.0

3.0.0PHP ^7.1.3

3.1.0PHP ^7.3 || ^8.0

4.0.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5520702?v=4)[konekt](/maintainers/konekt)[@konekt](https://github.com/konekt)

---

Top Contributors

[![fulopattila122](https://avatars.githubusercontent.com/u/1162360?v=4)](https://github.com/fulopattila122 "fulopattila122 (107 commits)")[![marcmascort](https://avatars.githubusercontent.com/u/3595718?v=4)](https://github.com/marcmascort "marcmascort (4 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (3 commits)")[![sandort](https://avatars.githubusercontent.com/u/6926708?v=4)](https://github.com/sandort "sandort (1 commits)")

---

Tags

enumphp-enumenumkonektartkonekt

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/konekt-enum/health.svg)

```
[![Health](https://phpackages.com/badges/konekt-enum/health.svg)](https://phpackages.com/packages/konekt-enum)
```

###  Alternatives

[myclabs/php-enum

PHP Enum implementation

2.7k236.1M695](/packages/myclabs-php-enum)[dasprid/enum

PHP 7.1 enum implementation

382165.7M12](/packages/dasprid-enum)[spatie/enum

PHP Enums

85232.6M75](/packages/spatie-enum)[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

50458.3M110](/packages/marc-mabe-php-enum)[spatie/laravel-enum

Laravel Enum support

3685.8M35](/packages/spatie-laravel-enum)[konekt/enum-eloquent

Enum attribute casting for Eloquent models

632.2M20](/packages/konekt-enum-eloquent)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
