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

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

elao/enum
=========

Extended PHP enums capabilities and frameworks integrations

v2.5.3(11mo ago)3273.2M↓15.8%30[15 issues](https://github.com/Elao/PhpEnums/issues)[3 PRs](https://github.com/Elao/PhpEnums/pulls)10MITPHPPHP &gt;=8.1CI failing

Since Nov 6Pushed 8mo ago18 watchersCompare

[ Source](https://github.com/Elao/PhpEnums)[ Packagist](https://packagist.org/packages/elao/enum)[ Docs](https://github.com/Elao/PhpEnums)[ GitHub Sponsors](https://github.com/ogizanagi)[ RSS](/packages/elao-enum/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (10)Dependencies (18)Versions (58)Used By (10)

Elao Enumerations
=================

[](#elao-enumerations)

[![Latest Version](https://camo.githubusercontent.com/0f8b8a8b40a9bd27bc073cf782e59ffdfd8dbb228f270560d8e35ea48a95438b/68747470733a2f2f706f7365722e707567782e6f72672f656c616f2f656e756d2f763f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/elao/enum)[![Total Downloads](https://camo.githubusercontent.com/901ec52931eb06fff189f097b5427a6a66d3ab0f763a8f8595d75738a520fbd9/68747470733a2f2f706f7365722e707567782e6f72672f656c616f2f656e756d2f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/elao/enum)[![Monthly Downloads](https://camo.githubusercontent.com/d7ef52048ed5274113b59f7f3a29bda5cc6bb00d8247dbd9b1c96e3946545e0c/68747470733a2f2f706f7365722e707567782e6f72672f656c616f2f656e756d2f642f6d6f6e74686c793f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/elao/enum)[![Tests](https://github.com/Elao/PhpEnums/actions/workflows/ci.yml/badge.svg)](https://github.com/Elao/PhpEnums/actions/workflows/ci.yml)[![Coveralls](https://camo.githubusercontent.com/6001f4253360dea5c57d59b8eb2cdc5e577d59e02ac29c5b286738deb97118ea/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f456c616f2f506870456e756d732e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/Elao/PhpEnums)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/87fef2e35adfa9e1625504f9802a3db728a719263a48ce6b8c9ef405629e9bb7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f456c616f2f506870456e756d732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Elao/PhpEnums/?branch=2.x)[![php](https://camo.githubusercontent.com/6080b0d2342847d6c57c829066cefe7fa257475efbfb982bac9f0f0f79aa7983/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312d677265656e2e7376673f7374796c653d666c61742d737175617265 "Available for PHP 8.1+")](http://php.net)

*Provides additional, opinionated features to the [PHP 8.1+ native enums](https://php.watch/versions/8.1/enums) as well as specific integrations with frameworks and libraries.*

```
#[ReadableEnum(prefix: 'suit.')]
enum Suit: string implements ReadableEnumInterface
{
    use ReadableEnumTrait;

    case Hearts = '♥︎';
    case Diamonds = '♦︎';
    case Clubs = '♣︎';
    case Spades = '︎♠︎';
}
```

---

 **📢 This project used to emulate enumerations before PHP 8.1.**
 For the 1.x documentation, [click here](https://github.com/Elao/PhpEnums/tree/1.x)

 You can also consult [this issue](https://github.com/Elao/PhpEnums/issues/124) to follow objectives &amp; progress for the V2 of this lib.

---

- Features
    - [Readable enums](#readable-enums)
    - [Flag enums](#flag-enums)
    - [Extra values](#extra-values)
- [Integrations](#integrations)
    - [Symfony Forms](#symfony-form)
    - [Symfony Controller Argument Resolver](#symfony-httpkernel)
    - Symfony VarDumper
    - [Symfony Translation](#symfony-translation)
    - [Doctrine ORM](#doctrine)
    - [Doctrine ODM](#doctrine-odm)
    - [Faker](#faker)

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

[](#installation)

```
composer require "elao/enum:^2.0"
```

Or, in order to help and test latest changes:

```
composer require "elao/enum:^2.x-dev"
```

Readable enums
--------------

[](#readable-enums)

Readable enums provide a way to expose human-readable labels for your enum cases, by adding a new `ReadableEnumInterface` contract to your enums.

The easiest way to implement this interface is by using the [`ReadableEnumTrait`](src/ReadableEnumTrait.php) and the [`EnumCase`](src/Attribute/EnumCase.php) attribute:

```
namespace App\Enum;

use Elao\Enum\ReadableEnumInterface;
use Elao\Enum\ReadableEnumTrait;
use Elao\Enum\Attribute\EnumCase;

enum Suit: string implements ReadableEnumInterface
{
    use ReadableEnumTrait;

    #[EnumCase('suit.hearts')]
    case Hearts = '♥︎';

    #[EnumCase('suit.diamonds')]
    case Diamonds = '♦︎';

    #[EnumCase('suit.clubs')]
    case Clubs = '♣︎';

    #[EnumCase('suit.spades')]
    case Spades = '︎♠︎';
}
```

The following snippet shows how to get the human-readable value of an enum:

```
Suit::Hearts->getReadable(); // returns 'suit.hearts'
```

It defines a proper contract to expose an enum case label instead of using the enum case internal name. Which is especially useful if the locale to expose labels to your users differs from the one you're writing your code, as well as for creating integrations with libraries requiring to expose such labels.

It's also especially useful in conjunction with a translation library like [Symfony's Translation component](https://symfony.com/doc/current/translation.html), by using translation keys.

Given the following translation file:

```
# translations/messages.fr.yaml
suit.hearts: 'Coeurs'
suit.diamonds: 'Carreaux'
suit.clubs: 'Piques'
suit.spades: 'Trèfles'
```

```
$enum = Suit::Hearts;
$translator->trans($enum->getReadable(), locale: 'fr'); // returns 'Coeurs'
```

### Configure suffix/prefix &amp; default value

[](#configure-suffixprefix--default-value)

As a shorcut, you can also use the [`ReadableEnum`](src/Attribute/ReadableEnum.php) attribute to define the common `suffix` and `prefix` to use, as well as defaulting on the enum case name or value, if not provided explicitly:

```
#[ReadableEnum(prefix: 'suit.')]
enum Suit: string implements ReadableEnumInterface
{
    use ReadableEnumTrait;

    #[EnumCase('hearts︎')]
    case Hearts = '♥︎';
    case Diamonds = '♦︎';
    case Clubs = '♣︎';
    case Spades = '︎♠︎';
}

Suit::Hearts->getReadable(); // returns 'suit.hearts'
Suit::Clubs->getReadable(); // returns 'suit.Clubs'
```

using the case value (only for string backed enums):

```
#[ReadableEnum(prefix: 'suit.', useValueAsDefault: true)]
enum Suit: string implements ReadableEnumInterface
{
    use ReadableEnumTrait;

    case Hearts = 'hearts';
    case Diamonds = 'diamonds';
    case Clubs = 'clubs︎';
    case Spades = '︎spades';
}

Suit::Hearts->getReadable(); // returns 'suit.hearts'
Suit::Clubs->getReadable(); // returns 'suit.clubs'
```

Extra values
------------

[](#extra-values)

The `EnumCase` attributes also provides you a way to configure some extra attributes on your cases and access these easily with the `ExtrasTrait`:

```
namespace App\Enum;

use Elao\Enum\ReadableEnumInterface;
use Elao\Enum\ExtrasTrait;
use Elao\Enum\Attribute\EnumCase;

enum Suit implements ReadableEnumInterface
{
    use ExtrasTrait;

    #[EnumCase(extras: ['icon' => 'fa-heart', 'color' => 'red'])]
    case Hearts;

    #[EnumCase(extras: ['icon' => 'fa-diamond', 'color' => 'red'])]
    case Diamonds;

    #[EnumCase(extras: ['icon' => 'fa-club', 'color' => 'black'])]
    case Clubs;

    #[EnumCase(extras: ['icon' => 'fa-spade', 'color' => 'black'])]
    case Spades;
}
```

Access these infos using `ExtrasTrait::getExtra(string $key, bool $throwOnMissingExtra = false): mixed`:

```
Suit::Hearts->getExtra('color'); // 'red'
Suit::Spades->getExtra('icon'); // 'fa-spade'
Suit::Spades->getExtra('missing-key'); // null
Suit::Spades->getExtra('missing-key', true); // throws
```

or create your own interfaces/traits:

```
interface RenderableEnumInterface
{
    public function getColor(): string;
    public function getIcon(): string;
}

use Elao\Enum\ExtrasTrait;

trait RenderableEnumTrait
{
    use ExtrasTrait;

    public function getColor(): string
    {
        $this->getExtra('color', true);
    }

    public function getIcon(): string
    {
        $this->getExtra('icon', true);
    }
}

use Elao\Enum\Attribute\EnumCase;

enum Suit implements RenderableEnumInterface
{
    use RenderableEnumTrait;

    #[EnumCase(extras: ['icon' => 'fa-heart', 'color' => 'red'])]
    case Hearts;

    // […]
}

Suit::Hearts->getColor(); // 'red'
```

Flag enums
----------

[](#flag-enums)

Flagged enumerations are used for bitwise operations.

```
namespace App\Enum;

enum Permissions: int
{
    case Execute = 1 value // 7
// or initiate a bag with all its possible values using:
$permissions = FlagBag::fromAll(Permissions::class);

$permissions = $permissions->withoutFlags(Permissions::Execute); // Returns an instance without "execute" flag

$permissions->getValue(); // Returns 6, i.e: the encoded bits value
$permissions->getBits(); // Returns [2, 4], i.e: the decoded bits
$permissions->getFlags(); // Returns [Permissions::Write, Permissions::Read]

$permissions = $permissions->withoutFlags(Permissions::Read, Permissions::Write); // Returns an instance without "read" and "write" flags
$permissions->getBits(); // Returns []
$permissions->getFlags(); // Returns []

$permissions = new FlagBag(Permissions::class, FlagBag::NONE); // Returns an empty bag

$permissions = $permissions->withFlags(Permissions::Read, Permissions::Execute); // Returns an instance with "read" and "execute" flags

$permissions->hasFlags(Permissions::Read); // True
$permissions->hasFlags(Permissions::Read, Permissions::Execute); // True
$permissions->hasFlags(Permissions::Write); // False
```

Hence, using `FlagBag::getValue()` you can get an encoded value for any combination of flags from your enum, and use it for storage or communication between your processes.

Integrations
------------

[](#integrations)

### Symfony Form

[](#symfony-form)

Symfony already provides an [EnumType](https://symfony.com/doc/current/reference/forms/types/enum.html)for allowing the user to choose one or more options defined in a PHP enumeration.
It extends the ChoiceType field and defines the same options.

However, it uses the enum case name as label, which might not be convenient.
Since this library specifically supports readable enums, it ships its own [EnumType](src/Bridge/Symfony/Form/Type/EnumType.php), extending Symfony's one and using the human representation of each case instead of their names.

Use it instead of Symfony's one:

```
namespace App\Form\Type;

use App\Enum\Suit;
use Symfony\Component\Form\AbstractType;
use Elao\Enum\Bridge\Symfony\Form\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;

class CardType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('suit', EnumType::class, [
                'class' => Suit::class,
                'expanded' => true,
            ])
        ;
    }

    // ...
}
```

#### FlagBag Form Type

[](#flagbag-form-type)

If you want to use `FlagBag` in Symfony Forms, use the [FlagBagType](src/Bridge/Symfony/Form/Type/FlagBagType.php). This type also extends Symfony [EnumType](https://symfony.com/doc/current/reference/forms/types/enum.html), but it transforms form values to and from `FlagBag` instances.

```
namespace App\Form\Type;

use App\Enum\Permissions;
use Symfony\Component\Form\AbstractType;
use Elao\Enum\Bridge\Symfony\Form\Type\FlagBagType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;

class AuthenticationType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('permission', FlagBagType::class, [
                'class' => Permissions::class,
            ])
        ;
    }

    // ...
}
```

### Symfony HttpKernel

[](#symfony-httpkernel)

#### Resolve controller arguments from route path

[](#resolve-controller-arguments-from-route-path)

As of Symfony 6.1+, [backed enum cases will be resolved](https://github.com/symfony/symfony/pull/44831) from route path parameters:

```
class CardController
{
    #[Route('/cards/{suit}')]
    public function list(Suit $suit): Response
    {
        // [...]
    }
}
```

➜ A call to `/cards/H` will resolve the `$suit` argument as the `Suit::Hearts` enum case.

If you're not yet using Symfony HttpKernel 6.1+, this library will still make this working by registering its own resolver.

#### Resolve controller arguments from query or body

[](#resolve-controller-arguments-from-query-or-body)

You can also resolve from query params or from the request body:

```
use Elao\Enum\Bridge\Symfony\HttpKernel\Controller\ArgumentResolver\Attributes\BackedEnumFromQuery;

class DefaultController
{
    #[Route('/cards')]
    public function list(
        #[BackedEnumFromQuery]
        ?Suit $suit = null,
    ): Response
    {
        // [...]
    }
}
```

➜ A call to `/cards?suit=H` will resolve the `$suit` argument as the `Suit::Hearts` enum case.

Use `BackedEnumFromBody` to resolve from the request body (`$_POST`).

It also supports variadics:

```
use Elao\Enum\Bridge\Symfony\HttpKernel\Controller\ArgumentResolver\Attributes\BackedEnumFromQuery;

class DefaultController
{
    #[Route('/cards')]
    public function list(
        #[BackedEnumFromQuery]
        ?Suit ...$suits = null,
    ): Response
    {
        // [...]
    }
}
```

➜ A call to `/cards?suits[]=H&suits[]=S` will resolve the `$suits` argument as `[Suit::Hearts, Suit::Spades]`.

### Symfony Translation

[](#symfony-translation)

Because the `ReadableEnumInterface` can be translated within the `TranslatorInterface`, it is easy to use `TranslatableInterface` to enums.

To translate readable enums is just matter to have a call:

```
public function trans(TranslatorInterface $translator, string $locale = null): string
{
    return $translator->trans($this->getReadable(), [], $locale);
}
```

An interface and a trait have been added for that purpose.

```
use Elao\Enum\Bridge\Symfony\Translation\TranslatableEnumInterface;
use Elao\Enum\Bridge\Symfony\Translation\TranslatableEnumTrait;

enum Card: string implements TranslatableEnumInterface
{
    use TranslatableEnumTrait;

    #[EnumCase('suit.hearts')]
    case Hearts = '♥︎';
    // ...
}
```

We then use in **PHP**:

```
$translated = Card::Hearts->trans($this->translator)
```

Or in **Twig**:

```
{{ game.card|trans }}
```

### Doctrine

[](#doctrine)

As of `doctrine/orm` 2.11, PHP 8.1 enum types [are supported natively](https://twitter.com/ogizanagi/status/1480456881265012736?s=20):

```
#[Entity]
class Card
{
    #[Column(type: 'string', enumType: Suit::class)]
    public $suit;
}
```

> **Note**: Unless you have specific needs for a DBAL type as described below, we recommend using the official ORM integration for backed enums.

PhpEnums however also provides some base classes to save your PHP backed enumerations in your database. Custom DBAL classes for use-cases specific to this library, such as storing a [flag bag](#flag-enums) or a collection of backed enum cases, are or will also be available.

#### In a Symfony app

[](#in-a-symfony-app)

This configuration is equivalent to the following sections explaining how to create a custom Doctrine DBAL type:

```
elao_enum:
  doctrine:
    types:
      App\Enum\Suit: ~ # Defaults to `{ class: App\Enum\Suit, default: null, type: single }`
      permissions: { class: App\Enum\Permission } # You can set a name different from the enum FQCN
      permissions_bag: { class: App\Enum\Permissions, type: flagbag } # values are stored as an int and retrieved as FlagBag object
      App\Enum\RequestStatus: { default: 200 } # Default value from enum cases, in case the db value is NULL
```

It'll actually generate &amp; register the types classes for you, saving you from writing this boilerplate code.

#### Manually

[](#manually)

Read the [Doctrine DBAL docs](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/custom-mapping-types.html)first.

Extend the [AbstractEnumType](src/Bridge/Doctrine/DBAL/Types/AbstractEnumType.php):

```
namespace App\Doctrine\DBAL\Type;

use Elao\Enum\Bridge\Doctrine\DBAL\Types\AbstractEnumType;
use App\Enum\Suit;

class SuitType extends AbstractEnumType
{
    protected function getEnumClass(): string
    {
        return Suit::class; // By default, the enum FQCN is used as the DBAL type name as well
    }
}
```

In your application bootstrapping code:

```
use App\Doctrine\DBAL\Type\SuitType;
use Doctrine\DBAL\Types\Type;

Type::addType(Suit::class, SuitType::class);
```

To convert the underlying database type of your new "Suit" type directly into an instance of `Suit` when performing schema operations, the type has to be registered with the database platform as well:

```
$conn = $em->getConnection();
$conn->getDatabasePlatform()->registerDoctrineTypeMapping(Suit::class, SuitType::class);
```

Then, use it as a column type:

```
use App\Enum\Suit;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
class Card
{
    #[ORM\Column(Suit::class, nullable: false)]
    private Suit $field;
}
```

### Troubleshooting

[](#troubleshooting)

#### Using enum instances with a QueryBuilder

[](#using-enum-instances-with-a-querybuilder)

When using enum instance as parameters in a query made with `Doctrine\ORM\QueryBuilder`and generated DBAL types from the bundle, parameter type might not be inferred correctly.

Either explicitly use enum value instead of an instance, or pass the registered DBAL type as the 3rd parameter in `setParameter()`to allow the query builder to cast the object to the database value correctly.

I.E, given:

```
#[ORM\Entity]
class Card
{
    #[ORM\Column(Suit::class, nullable: true)
    protected ?Suit $suit = null;
}
```

Use one of the following methods:

```
private function findByType(?Suit $suit = null): array
{
    $qb = $em->createQueryBuilder()
      ->select('c')
      ->from('Card', 'c')
      ->where('c.suit = :suit');

    // use a value from constants:
    $qb->setParameter('param1', Suit::SPADES->value);

    // or from instances:
    $qb->setParameter('suit', $suit->value);
    // Use the 3rd parameter to set the DBAL type
    $qb->setParameter('suit', $suit, Suit::class);

    // […]
}
```

### Doctrine ODM

[](#doctrine-odm)

You can store enumeration values as string or integer in your MongoDB database and manipulate them as objects thanks to custom mapping types included in this library.

In a near future, custom ODM classes for use-cases specific to this library, such as storing a flag bag or a collection of backed enum cases, would also be provided.

#### In a Symfony app

[](#in-a-symfony-app-1)

This configuration is equivalent to the following sections explaining how to create a custom Doctrine ODM type:

```
elao_enum:
  doctrine_mongodb:
    types:
      App\Enum\Suit: ~ # Defaults to `{ class: App\Enum\Suit, type: single }`
      permissions: { class: App\Enum\Permission } # You can set a name different from the enum FQCN
      another: { class: App\Enum\AnotherEnum, type: collection } # values are stored as an array of integers or strings
      App\Enum\RequestStatus: { default: 200 } # Default value from enum cases, in case the db value is NULL
```

It'll actually generate &amp; register the types classes for you, saving you from writing this boilerplate code.

#### Manually

[](#manually-1)

Read the [Doctrine ODM docs](https://www.doctrine-project.org/projects/doctrine-mongodb-bundle/en/current/config.html#custom-types)first.

Extend the [AbstractEnumType](src/Bridge/Doctrine/ODM/Types/AbstractEnumType.php) or [AbstractCollectionEnumType](src/Bridge/Doctrine/ODM/Types/AbstractCollectionEnumType.php):

```
namespace App\Doctrine\ODM\Type;

use Elao\Enum\Bridge\Doctrine\ODM\Types\AbstractEnumType;
use App\Enum\Suit;

class SuitType extends AbstractEnumType
{
    protected function getEnumClass(): string
    {
        return Suit::class; // By default, the enum FQCN is used as the DBAL type name as well
    }
}
```

In your application bootstrapping code:

```
use App\Doctrine\ODM\Type\SuitType;
use Doctrine\ODM\MongoDB\Types\Type;

Type::addType(Suit::class, SuitType::class);
```

#### Mapping

[](#mapping)

Now the new type can be used when mapping fields:

```
use App\Enum\Suit;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

#[MongoDB\Document]
class Card
{
    #[MongoDB\Field(Suit::class)]
    private Suit $field;
}
```

### Faker

[](#faker)

The PhpEnums library provides a faker `EnumProvider` allowing to select random enum cases:

```
use \Elao\Enum\Bridge\Faker\Provider\EnumProvider;

$faker = new Faker\Generator();
$faker->addProvider(new EnumProvider());

$faker->randomEnum(Suit::class) // Select one of the Suit cases, e.g: `Suit::Hearts`
$faker->randomEnums(Suit::class, 2, min: 1) // Select between 1 and 2 enums cases, e.g: `[Suit::Hearts, Suit::Spades]`
$faker->randomEnums(Suit::class, 3, exact: true) // Select exactly 3 enums cases
```

Its constructor receives a mapping of enum types aliases as first argument:

```
new EnumProvider([
    'Civility' => App\Enum\Civility::class,
    'Suit' => App\Enum\Suit::class,
]);
```

This is especially useful when using this provider with Nelmio Alice's DSL (*see next section*)

### Usage with Alice

[](#usage-with-alice)

If you're using the [nelmio/alice](https://github.com/nelmio/alice) package and its bundle in order to generate fixtures, you can register the Faker provider by using the `nelmio_alice.faker.generator`:

```
# config/services.yaml
services:
    Elao\Enum\Bridge\Faker\Provider\EnumProvider:
        arguments:
            - Civility: App\Enum\Civility
              Suit: App\Enum\Suit
        tags: ['nelmio_alice.faker.provider']
```

The following example shows how to use the provider within a [PHP fixture file](https://github.com/nelmio/alice/blob/master/doc/complete-reference.md#php):

```
return [
    MyEntity::class => [
        'entity1' => [
            'civility' => Civility::MISTER // Select a specific case, using PHP directly
            'suit' => '' // Select a random case
            'suit' => '' // Select a random case, using the FQCN alias
            'permissions' => '' // Select between 1 and 2 enums cases
            'permissions' => '' // Select exactly 3 enums cases
        ]
    ]
]
```

###  Health Score

64

—

FairBetter than 99% of packages

Maintenance55

Moderate activity, may be stable

Popularity61

Solid adoption and visibility

Community39

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 83% 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 ~55 days

Recently: every ~91 days

Total

58

Last Release

347d ago

Major Versions

v0.5.0 → v1.0.02016-12-09

v1.17.0 → v2.0.0-alpha.12021-12-30

v1.17.1 → v2.0.0-alpha.22022-01-24

1.x-dev → v2.2.02023-03-24

PHP version history (3 changes)v0.1.0PHP &gt;=7.0

v1.13.0PHP &gt;=7.3

v2.0.0-alpha.1PHP &gt;=8.1

### Community

Maintainers

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

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

---

Top Contributors

[![ogizanagi](https://avatars.githubusercontent.com/u/2211145?v=4)](https://github.com/ogizanagi "ogizanagi (371 commits)")[![michnovka](https://avatars.githubusercontent.com/u/16553087?v=4)](https://github.com/michnovka "michnovka (11 commits)")[![IonBazan](https://avatars.githubusercontent.com/u/1985514?v=4)](https://github.com/IonBazan "IonBazan (10 commits)")[![xavier-rdo](https://avatars.githubusercontent.com/u/1587796?v=4)](https://github.com/xavier-rdo "xavier-rdo (8 commits)")[![benji07](https://avatars.githubusercontent.com/u/166890?v=4)](https://github.com/benji07 "benji07 (8 commits)")[![pluk77](https://avatars.githubusercontent.com/u/524179?v=4)](https://github.com/pluk77 "pluk77 (4 commits)")[![laurentmuller](https://avatars.githubusercontent.com/u/4330059?v=4)](https://github.com/laurentmuller "laurentmuller (4 commits)")[![ostrolucky](https://avatars.githubusercontent.com/u/496233?v=4)](https://github.com/ostrolucky "ostrolucky (4 commits)")[![chalasr](https://avatars.githubusercontent.com/u/7502063?v=4)](https://github.com/chalasr "chalasr (4 commits)")[![IndraGunawan](https://avatars.githubusercontent.com/u/2704730?v=4)](https://github.com/IndraGunawan "IndraGunawan (3 commits)")[![danut007ro](https://avatars.githubusercontent.com/u/1083134?v=4)](https://github.com/danut007ro "danut007ro (3 commits)")[![kevinlelo](https://avatars.githubusercontent.com/u/9944472?v=4)](https://github.com/kevinlelo "kevinlelo (2 commits)")[![mbrodala](https://avatars.githubusercontent.com/u/5037116?v=4)](https://github.com/mbrodala "mbrodala (2 commits)")[![marvincaspar](https://avatars.githubusercontent.com/u/2600346?v=4)](https://github.com/marvincaspar "marvincaspar (1 commits)")[![bendavies](https://avatars.githubusercontent.com/u/625392?v=4)](https://github.com/bendavies "bendavies (1 commits)")[![B-Galati](https://avatars.githubusercontent.com/u/895123?v=4)](https://github.com/B-Galati "B-Galati (1 commits)")[![devster](https://avatars.githubusercontent.com/u/1135083?v=4)](https://github.com/devster "devster (1 commits)")[![eliashaeussler](https://avatars.githubusercontent.com/u/16313625?v=4)](https://github.com/eliashaeussler "eliashaeussler (1 commits)")[![ker0x](https://avatars.githubusercontent.com/u/5331654?v=4)](https://github.com/ker0x "ker0x (1 commits)")[![alanpoulain](https://avatars.githubusercontent.com/u/10920253?v=4)](https://github.com/alanpoulain "alanpoulain (1 commits)")

---

Tags

enumenumerationhacktoberfestphpsymfonysymfonyenumdoctrine

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[fresh/doctrine-enum-bundle

Provides support of ENUM type for Doctrine2 in Symfony applications.

4636.8M12](/packages/fresh-doctrine-enum-bundle)[api-platform/schema-generator

Various tools to generate a data model based on Schema.org vocables

4714.2M7](/packages/api-platform-schema-generator)[ambta/doctrine-encrypt-bundle

Symfony 2 bundle which allows to encrypt data in database with some encrypt algorithm

77275.7k](/packages/ambta-doctrine-encrypt-bundle)[prezent/doctrine-translatable-bundle

Integrate the doctrine-translatable extension in Symfony

14698.4k5](/packages/prezent-doctrine-translatable-bundle)[ao/translation-bundle

Doctrine as symfony translation provider + a nice gui for editing translations.

243.7k](/packages/ao-translation-bundle)

PHPackages © 2026

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