PHPackages                             henzeb/enumhancer - 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. [Database &amp; ORM](/categories/database)
4. /
5. henzeb/enumhancer

ActiveLibrary[Database &amp; ORM](/categories/database)

henzeb/enumhancer
=================

Your framework-agnostic Swiss Army knife for PHP 8.1+ native enums

v3.2.1(4mo ago)69287.4k↑17.5%8[1 PRs](https://github.com/henzeb/enumhancer/pulls)2AGPL-3.0-onlyPHPPHP ^8.1CI passing

Since Feb 15Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/henzeb/enumhancer)[ Packagist](https://packagist.org/packages/henzeb/enumhancer)[ Docs](https://github.com/henzeb/enumhancer)[ RSS](/packages/henzeb-enumhancer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (56)Used By (2)

Enumhancer
==========

[](#enumhancer)

[![Build Status](https://github.com/henzeb/enumhancer/workflows/tests/badge.svg)](https://github.com/henzeb/enumhancer/actions)[![Code Coverage](https://camo.githubusercontent.com/0b3d22778135293bca2e88de1a8fe22559814731481df0f85891539016726fe7/68747470733a2f2f716c74792e73682f67682f68656e7a65622f70726f6a656374732f656e756d68616e6365722f636f7665726167652e737667)](https://qlty.sh/gh/henzeb/projects/enumhancer)[![Total Downloads](https://camo.githubusercontent.com/1f01fe1f1f670529a95e1ec107392b37404e025a984c7cb021a3685c38eaf331/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68656e7a65622f656e756d68616e6365722e737667)](https://packagist.org/packages/henzeb/enumhancer)[![Latest Version on Packagist](https://camo.githubusercontent.com/c6b4743d0a33561fc592a2b9083cd5ba43d2d4af97234c10492336ce15d05396/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68656e7a65622f656e756d68616e6365722e737667)](https://packagist.org/packages/henzeb/enumhancer)[![License](https://camo.githubusercontent.com/d7c282f622545f28ae616acb28eda02fc8ea0811dfab41556e7cc99c502f00ad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f68656e7a65622f656e756d68616e636572)](https://packagist.org/packages/henzeb/enumhancer)

This package is your framework-agnostic Swiss Army knife when it comes to PHP 8.1's native enums. In this package you will find a lot of tools for the most common use cases, and more will be added in the future.

If you have an idea, or you miss something that needs to be added, just let me know.

Enumhancer is case-agnostic, which means `Enum` equals `ENUM` equals `enum`. This is done with the idea that it is useless to have two different enums having the same name and different casing.

It is also type-agnostic. This way you can steer clear as much as possible from the extra work that comes with backed enums.

Note: While most functionality that also exists in Spatie's PHP Enum is made backwards compatible to allow for an easy migration to PHP native enums, currently this is not the case for their laravel package, PHPUnit assertions or Faker Provider.

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

[](#installation)

You can install the package via composer:

```
composer require henzeb/enumhancer
```

Usage
-----

[](#usage)

You can simply add the `Enhancers` trait to your `enum` in order to use almost all functionality of this package. All features should work with `basic` enums as well as `backed` enums' unless stated otherwise.

```
use Henzeb\Enumhancer\Concerns\Enhancers;

enum YourEnum {
    use Enhancers;

    // ...
}
```

You can also just use one of the features by using the specific trait for that feature.

Note: all traits can be used next to each other, except for `Mappers`, which has implemented the methods of `Getters`, `Extractor` and `Reporters`.

### Features

[](#features)

- [Attributes](docs/attributes.md)
- [Bitmasks](docs/bitmasks.md)
- [Constructor](docs/constructor.md)
- [Comparison](docs/comparison.md)
- [Configure](docs/configure.md)
- [Defaults](docs/defaults.md)
- [Dropdown](docs/dropdown.md)
- [Extractor](docs/extractor.md)
- [From](docs/from.md)
- [Getters](docs/getters.md)
- [Labels](docs/labels.md)
- [Macros](docs/macros.md)
- [Mappers](docs/mappers.md)
- [Properties](docs/properties.md)
- [Reporters](docs/reporters.md)
- [State](docs/state.md)
- [Subset](docs/subset.md)
- [Value](docs/value.md)

### Helper functions

[](#helper-functions)

- [Backing](docs/functions.md#backing)
- [Name](docs/functions.md#name)
- [Value](docs/functions.md#value)

### Development

[](#development)

- [IDE-Helper](docs/ide-helper.md)
- [PHPstan](docs/phpstan.md)

### Laravel specific Features

[](#laravel-specific-features)

- [Blade](docs/blade.md)
- [Casting](docs/casting.md)
- [FormRequest](docs/formrequests.md)
- [Implicit (basic) enum binding](docs/binding.md)
- [Validation](docs/laravel.validation.md)

### Laravel's auto-discovery

[](#laravels-auto-discovery)

When you are installing this package into a laravel project, Enumhancer will automatically set macro's for the `validation rules` and sets the global `Reporter` for the `getOrReport` methods, so that it will use Laravel's `Log` facade.

If you don't want that to happen, you can tell Laravel not to discover the package.

```
"extra": {
        "laravel": {
            "dont-discover": [
                "henzeb/enumhancer"
            ]
        }
    }

```

### Testing

[](#testing)

```
composer test
```

#### PHPStan integration

[](#phpstan-integration)

If you are using PHPStan for static analysis, you can enable the extension.

Add the following to your projects phpstan.neon:

```
includes:
- vendor/henzeb/enumhancer/extension.neon

```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Henze Berkheij](https://github.com/henzeb)

License
-------

[](#license)

The GNU AGPLv. Please see [License File](LICENSE.md) for more information.

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance75

Regular maintenance activity

Popularity49

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 94% 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 ~27 days

Recently: every ~114 days

Total

53

Last Release

134d ago

Major Versions

v1.23.0 → v2.0.02023-02-28

v2.3.1 → v3.0.02025-05-09

### Community

Maintainers

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

---

Top Contributors

[![henzeb](https://avatars.githubusercontent.com/u/15928532?v=4)](https://github.com/henzeb "henzeb (79 commits)")[![BafS](https://avatars.githubusercontent.com/u/588205?v=4)](https://github.com/BafS "BafS (3 commits)")[![BinaryKitten](https://avatars.githubusercontent.com/u/67553?v=4)](https://github.com/BinaryKitten "BinaryKitten (1 commits)")[![mathroc](https://avatars.githubusercontent.com/u/291531?v=4)](https://github.com/mathroc "mathroc (1 commits)")

---

Tags

backedbasicenumenumerationenumslaravelnativephpspatieunitlaravelloggingvalidationstringenumeloquentbladereportingstatetransitionenumeratorcomparisonlistmacroableextractreportrulesbasicdropdownselectpropertiesextractorvaluebindingmachinecastingcastnativelabelsfromstringabledefaultmacrosbitmaskImplicitenumsenumeratorssubsetide-helpermappersphp 8.1henzebenumhancerbackedunitEnumbackedEnum8.1tryFromphp 8.28.2bitmasks

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/henzeb-enumhancer/health.svg)

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

###  Alternatives

[esensi/model

The base model traits of Esensi

20266.5k1](/packages/esensi-model)[altek/accountant

The auditing &amp; accountability package for Laravel's Eloquent ORM.

92954.3k4](/packages/altek-accountant)[rolfvreijdenberger/izzum-statemachine

A superior statemachine library php &gt;= 5.3. Integrates with your domain models perfectly.

7425.5k](/packages/rolfvreijdenberger-izzum-statemachine)[rennokki/eloquent-settings

Eloquent Settings allows you to bind key-value pairs to any Laravel Eloquent model. It supports even casting for boolean, float or integer types.

804.2k](/packages/rennokki-eloquent-settings)

PHPackages © 2026

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