# myclabs/php-enum

The enum PHP is missing, inspired from SplEnum

Repository: https://github.com/myclabs/php-enum
Canonical: https://ross.abutalabs.com/products/php-enum
Language: PHP
License: MIT
License Family: permissive
Topics: enum, php, php-enum
Last push: 2025-02-21T08:40:22+00:00

## Health v2 (maintenance only)
Score: 26/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 7, release rhythm 8, longevity 100
- inputs: {"age_days": 4970, "days_push": 558, "days_rel": 596, "gap_med": null, "n_releases_24m": 1}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2722, forks 127 (observed 2026-08-28T04:07:15.591639+00:00)

## What it is
A small PHP library providing an Enum base class, inspired by SplEnum, for PHP versions lacking native enums. It lets developers define enumerable constants as typed objects usable as parameter/return types with helper methods like from(), values(), and equals().

## Use cases
- use enums as parameter and return types in PHP
- get a list of all possible enum values
- compare enum instances for equality
- create enum instances from dynamic values
- add methods to enum types

## When to choose
- you are on PHP < 8.1 and need enum-like typed constants
- you want SplEnum behavior without installing a C extension
- you need enums with methods and type-hintable instances

## When to avoid
- you are on PHP 8.1+ where native enums are built in
- you only need simple class constants
- you need a heavily developed actively evolving library

## Facets
- artifact type: library
- maturity: maintenance
- function: type-system, serialization
- domain: programming-languages, developer-tools
- platform: php
- tags: enum, spl-enum, value-objects, composer-package

## Member repositories
- myclabs/php-enum (main) score 26

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:07:15.591639+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T02:15:11.779905+00:00, confidence not recorded.
  - readme: https://github.com/myclabs/php-enum (fetched 2026-08-28T04:07:15.591639+00:00, sha 6c8a77f023b6)
- Data as of 2026-08-30T08:39:29.467469+00:00.
