PHPackages                             heymoon/doctrine-psql-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. heymoon/doctrine-psql-enum

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

heymoon/doctrine-psql-enum
==========================

Store PHP native enums as PostgeSQL custom enum types

3.3.0(2mo ago)254.9k↓19.6%5[3 issues](https://github.com/heymoon-cc/doctrine-psql-enum/issues)MITPHPPHP &gt;=8.2CI passing

Since Jan 7Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/heymoon-cc/doctrine-psql-enum)[ Packagist](https://packagist.org/packages/heymoon/doctrine-psql-enum)[ RSS](/packages/heymoon-doctrine-psql-enum/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (18)Versions (17)Used By (0)

Doctrine enums for PostgreSQL
=============================

[](#doctrine-enums-for-postgresql)

[![Version](https://camo.githubusercontent.com/68de69f12a3636c919a4db7adcc83346c30efffd38c714fcfa6f5afa227f3650/68747470733a2f2f706f7365722e707567782e6f72672f6865796d6f6f6e2f646f637472696e652d7073716c2d656e756d2f76)](https://packagist.org/packages/heymoon/doctrine-psql-enum)[![PHP Version Require](https://camo.githubusercontent.com/dc6a5e7c5429524d0e778080fb736402930212fa19e5f05a3bd6454a558d5d7c/68747470733a2f2f706f7365722e707567782e6f72672f6865796d6f6f6e2f646f637472696e652d7073716c2d656e756d2f726571756972652f706870)](https://packagist.org/packages/heymoon/doctrine-psql-enum)[![Test](https://github.com/heymoon-cc/doctrine-psql-enum/actions/workflows/test.yaml/badge.svg)](https://github.com/heymoon-cc/doctrine-psql-enum/actions/workflows/test.yaml)[![Maintainability](https://camo.githubusercontent.com/5b52235628b715dcd8c84104e1c759c5fabd778544ca3e09c627a8b73c1cc79b/68747470733a2f2f716c74792e73682f6261646765732f38363637373839392d396639662d343063382d393563372d6231323030653032393934342f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/heymoon-cc/projects/doctrine-psql-enum)[![Code Coverage](https://camo.githubusercontent.com/8d2ac113c091aa5a7abbbeafab4fa533e3de8c78e84207dc5e292a16bc55cd1e/68747470733a2f2f716c74792e73682f6261646765732f38363637373839392d396639662d343063382d393563372d6231323030653032393934342f746573745f636f7665726167652e737667)](https://qlty.sh/gh/heymoon-cc/projects/doctrine-psql-enum)[![Matrix](https://camo.githubusercontent.com/ee48d48521578358fc2bd6c71f526a09a13c0ea6900d050dcf2ac45819af1322/68747470733a2f2f696d672e736869656c64732e696f2f6d61747269782f646f637472696e652d7073716c2d656e756d2533416865796d6f6f6e2e63633f66657463684d6f64653d6775657374)](https://matrix.to/#/#doctrine-psql-enum:heymoon.cc)

Prerequisites: *Symfony 7 + Doctrine 3*
---------------------------------------

[](#prerequisites-symfony-7--doctrine-3)

### Installation

[](#installation)

`composer require heymoon/doctrine-psql-enum`

### Usage

[](#usage)

Create library configuration:

`config/packages/doctrine_postgres_enum.yaml`

```
doctrine_postgres_enum:
  type_name: enum
  migrations:
    enabled: true
    comment_tag: DC2Enum
```

For defining new enum type, [use native PHP enums](https://www.php.net/manual/language.types.enumerations.php):

```
use HeyMoon\DoctrinePostgresEnum\Attribute\EnumType;

#[EnumType('auth_status')]
enum AuthStatus: string
{
    case New = 'new';
    case Active = 'active';
    case Inactive = 'inactive';
    case Deleted = 'deleted';
}

#[EnumType('auth_service')]
enum Service: string
{
    case Google = 'google';
}
```

For creation of enum-field in model, use `enum` as `type` value, `enumType` in `Column` attribute must be defined:

```
#[ORM\Entity(repositoryClass: AuthRepository::class)]
class Auth
{
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: "CUSTOM")]
    #[ORM\CustomIdGenerator(class: "doctrine.uuid_generator")]
    #[ORM\Column(type: 'uuid')]
    private Uuid $id;

    #[ORM\Column(type: 'enum', enumType: AuthStatus::class)]
    private AuthStatus $status;

    #[ORM\Column(type: 'enum', enumType: Service::class)]
    private Service $service;
}
```

Create migrations via `make:migration`. If enum was created or modified, the `CREATE TYPE`/`ALTER TYPE` calls would be added to migration. Example:

```
$this->addSql('DROP TYPE IF EXISTS auth_status');
$this->addSql('CREATE TYPE auth_status AS ENUM (\'new\',\'active\',\'inactive\',\'deleted\')');
$this->addSql('DROP TYPE IF EXISTS auth_service');
$this->addSql('CREATE TYPE auth_service AS ENUM (\'google\')');
$this->addSql('CREATE TABLE auth (id UUID NOT NULL, status auth_status NOT NULL, service auth_service NOT NULL, PRIMARY KEY(id))');
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity34

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.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 ~32 days

Recently: every ~27 days

Total

14

Last Release

70d ago

Major Versions

1.0.0 → 2.0.02025-01-07

2.1.1 → 3.0.02025-05-28

PHP version history (2 changes)1.0.0PHP &gt;=8.1

2.1.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b87e85a4fa81b0cf22cff5ede2eb41460a4bff02b8cd99d301fd8b7d23a8494?d=identicon)[heymoon](/maintainers/heymoon)

---

Top Contributors

[![egbuk](https://avatars.githubusercontent.com/u/1367406?v=4)](https://github.com/egbuk "egbuk (39 commits)")[![soyuka](https://avatars.githubusercontent.com/u/1321971?v=4)](https://github.com/soyuka "soyuka (6 commits)")[![ArnoudThibaut](https://avatars.githubusercontent.com/u/14937343?v=4)](https://github.com/ArnoudThibaut "ArnoudThibaut (2 commits)")[![MathieuSommit](https://avatars.githubusercontent.com/u/58809078?v=4)](https://github.com/MathieuSommit "MathieuSommit (1 commits)")

---

Tags

doctrine-ormpostgresqlenumpostgresqldoctrine-orm

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/heymoon-doctrine-psql-enum/health.svg)

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

###  Alternatives

[fresh/doctrine-enum-bundle

Provides support of ENUM type for Doctrine2 in Symfony applications.

4636.8M12](/packages/fresh-doctrine-enum-bundle)[scienta/doctrine-json-functions

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

58723.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)[hautelook/alice-bundle

Symfony bundle to manage fixtures with Alice and Faker.

19519.4M34](/packages/hautelook-alice-bundle)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)

PHPackages © 2026

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