A collection of strongly-typed constant enumerations for PHP β over 1,600 constants across 73 classes (general, HTTP, mail, JWT/JOSE, OAuth 2.0/OIDC), all sharing one reflection API through ConstantsTrait. No magic strings.
π Documentation
Narrative user guides (FR + EN), with examples and the full catalogue per namespace:
- π¬π§ English documentation
- π«π· Documentation franΓ§aise
You are currently browsing the auto-generated API reference (phpDocumentor).
π¦ Installation
This library requires PHP 8.4+ and is installed via Composer:
composer require oihana/php-enums
β¨ 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
HttpHeaderandMailHeaderβuseonly what you need. - βοΈ Domain helpers where they help (status descriptions, SMTP security, mail priority conversions, postal-code validation, β¦).
- π‘οΈ No magic strings β typo-safe, refactor-friendly, IDE-autocompleted.
β Tests & coverage
Run the 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 composer coverage:md
The suite covers 100% of lines (323/323). See the testing guide: English Β· FranΓ§ais.
π§Ύ License
This project is licensed under the Mozilla Public License 2.0 (MPL-2.0).
π€ About the Author
- Name: Marc ALCARAZ (aka eKameleon)
- Website: www.ooop.fr
- Email: marc@ooop.fr
π Related packages
- oihana/php-core β core helpers and utilities used by this library.
- oihana/php-reflect β reflection and hydration utilities (provides
ConstantsTrait).
π Project on GitHub
View the full source code and contribute on GitHub: github.com/BcommeBois/oihana-php-enums.