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

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

bentools/doctrine-native-enums
==============================

Provides 1st class suport for native PHP enums in Doctrine.

0.1.2(4y ago)14120.4k—8.8%2[1 PRs](https://github.com/bpolaszek/doctrine-native-enums/pulls)MITPHPPHP &gt;=8.1

Since Sep 15Pushed 3y ago2 watchersCompare

[ Source](https://github.com/bpolaszek/doctrine-native-enums)[ Packagist](https://packagist.org/packages/bentools/doctrine-native-enums)[ RSS](/packages/bentools-doctrine-native-enums/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (10)Versions (4)Used By (0)

[![CI Workflow](https://github.com/bpolaszek/doctrine-native-enums/actions/workflows/ci.yml/badge.svg)](https://github.com/bpolaszek/doctrine-native-enums/actions/workflows/ci.yml)[![Coverage](https://camo.githubusercontent.com/ac3b2217e128e036c8dd8f0d1cc8a58c309eb758afb2055aac5f16c6e8278f19/68747470733a2f2f636f6465636f762e696f2f67682f62706f6c61737a656b2f646f637472696e652d6e61746976652d656e756d732f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d327734333679306e345a)](https://codecov.io/gh/bpolaszek/doctrine-native-enums)

Doctrine Native Enums
=====================

[](#doctrine-native-enums)

This library provides support to [PHP Enums](https://wiki.php.net/rfc/enumerations), introduced in PHP 8.1, within your Doctrine entities.

⚠️ **Jan 2022: Doctrine ORM 2.11 finally introduced [native support](https://www.doctrine-project.org/2022/01/11/orm-2.11.html) for PHP 8.1 enums! 🎉**

**This means that this bundle will soon or later be discontinued. Please upgrade your dependencies!**

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

[](#installation)

```
composer require bentools/doctrine-native-enums
```

Usage
-----

[](#usage)

This library only works with [Backed enums](https://wiki.php.net/rfc/enumerations#backed_enums).

### In a Symfony project

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

#### 1. Declare the bundle.

[](#1-declare-the-bundle)

```
// config/bundles.php

return [
    // ...
    BenTools\Doctrine\NativeEnums\Bundle\DoctrineNativeEnumsBundle::class => ['all' => true],
];
```

#### 2. Register enums in your configuration.

[](#2-register-enums-in-your-configuration)

```
# config/packages/doctrine_native_enums.yaml

doctrine_native_enums:
  enum_types:
    App\Entity\StatusEnum: ~
    #App\Entity\StatusEnum: status # Alternatively, if you want your type to be named "status"
```

#### 3. Use them in your entities.

[](#3-use-them-in-your-entities)

```
declare(strict_types=1);

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
final class Book
{
    #[
        ORM\Id,
        ORM\Column(unique: true),
        ORM\GeneratedValue(strategy: 'AUTO'),
    ]
    public int $id;

    #[ORM\Column]
    public string $name;

    #[ORM\Column(type: StatusEnum::class)]
    public StatusEnum $status;
}
```

### In other projects using Doctrine

[](#in-other-projects-using-doctrine)

```
use App\Entity\StatusEnum;
use BenTools\Doctrine\NativeEnums\Type\NativeEnum;
use Doctrine\DBAL\Types\Type;

NativeEnum::registerEnumType(StatusEnum::class);
// NativeEnum::registerEnumType('status', StatusEnum::class); // Alternatively, if you want your type to be named "status"
```

Tests
-----

[](#tests)

```
php vendor/bin/pest
```

License
-------

[](#license)

MIT.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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 ~69 days

Total

3

Last Release

1568d ago

### Community

Maintainers

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

---

Top Contributors

[![bpolaszek](https://avatars.githubusercontent.com/u/5569077?v=4)](https://github.com/bpolaszek "bpolaszek (5 commits)")[![jonbk](https://avatars.githubusercontent.com/u/29717277?v=4)](https://github.com/jonbk "jonbk (1 commits)")

###  Code Quality

TestsPest

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/bentools-doctrine-native-enums/health.svg)

```
[![Health](https://phpackages.com/badges/bentools-doctrine-native-enums/health.svg)](https://phpackages.com/packages/bentools-doctrine-native-enums)
```

###  Alternatives

[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M36](/packages/scienta-doctrine-json-functions)[martin-georgiev/postgresql-for-doctrine

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

4485.3M4](/packages/martin-georgiev-postgresql-for-doctrine)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[worksome/foggy

Foggy is a tool for making database dumps with some data removed/changed.

26571.7k1](/packages/worksome-foggy)

PHPackages © 2026

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