PHPackages                             oihana/php-enums - 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. oihana/php-enums

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

oihana/php-enums
================

A collection of strongly-typed constant enumerations for PHP

1.2.3(1w ago)089513MPL-2.0PHPPHP &gt;=8.4CI passing

Since Aug 13Pushed 2w agoCompare

[ Source](https://github.com/BcommeBois/oihana-php-enums)[ Packagist](https://packagist.org/packages/oihana/php-enums)[ Docs](https://github.com/BcommeBois/oihana-php-reflect)[ RSS](/packages/oihana-php-enums/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (18)Versions (7)Used By (13)

Oihana PHP - Enums
==================

[](#oihana-php---enums)

[![Oihana PHP Enums](https://raw.githubusercontent.com/BcommeBois/oihana-php-enums/main/assets/images/oihana-php-enums-logo-inline-512x160.png)](https://raw.githubusercontent.com/BcommeBois/oihana-php-enums/main/assets/images/oihana-php-enums-logo-inline-512x160.png)

A collection of strongly-typed constant enumerations for PHP.

[![Latest Version](https://camo.githubusercontent.com/31694912939fd1c38dd6fb441ecba7bab15844d5722bbb097123b3e8a653349e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6968616e612f7068702d656e756d732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-enums) [![Total Downloads](https://camo.githubusercontent.com/caed1afe4d6d7ce0dea69351bb9a65e6e09e289088e8103bc2c6689eafeab0b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6968616e612f7068702d656e756d732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-enums) [![License](https://camo.githubusercontent.com/3d3c93f243c4b1ed7ebf21a5b0367b47c77677a457f0b0c4494ab81a5d30f6f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f6968616e612f7068702d656e756d732e7376673f7374796c653d666c61742d737175617265)](LICENSE)

`oihana/php-enums` bundles **over 1,600 constants** across **73 enumeration classes** in five domains — general, HTTP, mail/SMTP, JWT/JOSE and OAuth 2.0/OIDC. Every class is a **constant class** (not a native PHP `enum`) using `ConstantsTrait`, so they all share one reflection API — list, validate and reverse-look-up values without instantiating anything, and replace *magic strings* everywhere.

Framework-agnostic, PHP 8.4+, dependency-light.

📚 Documentation
---------------

[](#-documentation)

User guides (FR + EN) — getting started, the shared `ConstantsTrait` API, the full catalogue per namespace, convenience helpers, testing and tips:

🇬🇧 **[English documentation](wiki/en/README.md)**🇫🇷 **[Documentation française](wiki/fr/README.md)**Getting started, `ConstantsTrait`, general/HTTP/mail/JWT/OAuth2, helpers, tips.Démarrage, `ConstantsTrait`, général/HTTP/mail/JWT/OAuth2, helpers, astuces.Auto-generated API reference (phpDocumentor):
👉

🚀 Features
----------

[](#-features)

- 📦 **73 enumerations / 1,600+ constants** across general, HTTP, mail/SMTP, JWT/JOSE and OAuth 2.0/OIDC domains.
- 🔍 **One shared reflection API** via `ConstantsTrait` — `enums()`, `includes()`, `getConstant()`, `validate()` — identical on every class.
- 🧩 **Composable per-category traits** for `HttpHeader` and `MailHeader` — `use` only what you need.
- ⚙️ **Domain helpers** where they help — `HttpStatusCode::getDescription()`, `SmtpSecurity::scheme()`, `MailPriority::toXPriority()`, `PostalCodePattern::isValid()`, and more.
- 🛡️ **No *magic strings*** — typo-safe, refactor-friendly, IDE-autocompleted.

💡 No external dependencies beyond Oihana's core and reflection utilities.

📦 Installation
--------------

[](#-installation)

> **Requires [PHP 8.4+](https://php.net/releases/)**

Install via [Composer](https://getcomposer.org):

```
composer require oihana/php-enums
```

🚀 Quick start
-------------

[](#-quick-start)

```
use oihana\enums\Boolean;
use oihana\enums\Char;
use oihana\enums\http\HttpMethod;
use oihana\enums\http\HttpStatusCode;

$enabled = Boolean::TRUE;                  // 'true'
echo 'A' . Char::DOT . 'B';                // 'A.B'

HttpMethod::includes( 'GET' );             // true
HttpMethod::enums();                       // ['CONNECT', 'DELETE', 'GET', ...]
HttpStatusCode::getDescription( 404 );     // 'Not found'
```

The full catalogue lives in the wiki — [English](wiki/en/README.md#the-catalogue) · [Français](wiki/fr/README.md#le-catalogue).

✅ Tests &amp; coverage
----------------------

[](#-tests--coverage)

Run the full unit-test suite (PHPUnit, strict mode):

```
composer test
```

Run a single test case:

```
./vendor/bin/phpunit --filter HttpStatusCodeTest
```

Measure coverage (requires Xdebug or PCOV):

```
composer coverage        # text + Clover + HTML under build/coverage/
composer coverage:md     # readable Markdown summary (build/coverage/COVERAGE.md)
```

The suite covers **100% of lines** (323/323). For the testing philosophy and the `@codeCoverageIgnore` policy, see **[wiki/en/testing.md](wiki/en/testing.md)** · **[wiki/fr/testing.md](wiki/fr/testing.md)**.

🧾 License
---------

[](#-license)

This project is licensed under the [Mozilla Public License 2.0 (MPL-2.0)](https://www.mozilla.org/en-US/MPL/2.0/).

👤 About the author
------------------

[](#-about-the-author)

- Author : Marc ALCARAZ (aka eKameleon)
- Mail :
- Website :

🛠️ Generate the documentation
-----------------------------

[](#️-generate-the-documentation)

We use [phpDocumentor](https://phpdoc.org/) to generate the API reference into the `./docs` folder:

```
composer doc
```

`docs/` is gitignored and published to GitHub Pages by CI — it is not committed.

🔗 Related packages
------------------

[](#-related-packages)

- `oihana/php-core` – core helpers and utilities used by this library: `https://github.com/BcommeBois/oihana-php-core`
- `oihana/php-reflect` – reflection and hydration utilities (provides `ConstantsTrait`): `https://github.com/BcommeBois/oihana-php-reflect`

###  Health Score

50

↑

FairBetter than 95% of packages

Maintenance97

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~62 days

Recently: every ~6 days

Total

6

Last Release

12d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d234506e51778dd3d1d61b6c2af6f294ff963651b4aa509b595d3d2a77b7d89b?d=identicon)[ooop](/maintainers/ooop)

---

Top Contributors

[![ekameleon](https://avatars.githubusercontent.com/u/749032?v=4)](https://github.com/ekameleon "ekameleon (66 commits)")

---

Tags

phpconstantsenums

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/oihana-php-enums/health.svg)

```
[![Health](https://phpackages.com/badges/oihana-php-enums/health.svg)](https://phpackages.com/packages/oihana-php-enums)
```

PHPackages © 2026

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