PHPackages                             gusarov112/php-enum-doctrine - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. gusarov112/php-enum-doctrine

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gusarov112/php-enum-doctrine
============================

Allows to add you custom php enums as doctrine type

v1.0.2(5y ago)03MITPHPPHP ^7.1

Since Jul 11Pushed 5y agoCompare

[ Source](https://github.com/gusarov112/php-enum-doctrine)[ Packagist](https://packagist.org/packages/gusarov112/php-enum-doctrine)[ Docs](http://github.com/gusarov112/php-enum-doctrine)[ RSS](/packages/gusarov112-php-enum-doctrine/feed)WikiDiscussions master Synced today

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

Php Enum doctrine
=================

[](#php-enum-doctrine)

- Allows to add you custom php enums as doctrine type.
- Supports generation of correct alter SQL when updating enum values.

Extension for [php-enum](https://github.com/gusarov112/php-enum) (myclabs fork)

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

[](#installation)

Than require package

```
composer require gusarov112/php-enum-doctrine
```

Symfony configuration
---------------------

[](#symfony-configuration)

```
  Gusarov112\PhpEnumDoctrine\EventListener\EnumUpdaterSubscriber:
    tags:
      - { name: doctrine.event_subscriber }

```

Example
-------

[](#example)

### Create enum

[](#create-enum)

```
class PetEnum extends \Gusarov112\Enum\Enum
{
    const CAT = 'CAT';
    const DOG = 'DOG';
}
```

### Create corresponding enum type by extending abstract type

[](#create-corresponding-enum-type-by-extending-abstract-type)

```
class PetType extends \Gusarov112\PhpEnumDoctrine\DBAL\EnumType
{
    public function getEnumClassName(): string
    {
        return PetEnum::class;
    }

    public function getName()
    {
        return 'pet_type';
    }
}
```

### Use your column type in doctrine entity

[](#use-your-column-type-in-doctrine-entity)

```
use Doctrine\ORM\Mapping as ORM;

class PetEntity {
    /**
     * @var PetEnum
     * @ORM\Column(type="pet_type")
     */
    private $type;

    public function getType(): PetEnum
    {
        return $this->type;
    }

    public function setType(PetEnum $type): self
    {
        $this->type = $type;

        return $this;
    }
}
```

### Do not forger to register your type

[](#do-not-forger-to-register-your-type)

```
\Doctrine\DBAL\Types\Type::addType('pet_type', PetType::class);
```

### Add event subscriber if you have migrations bundle and want to autogenerate enum list alter SQL's

[](#add-event-subscriber-if-you-have-migrations-bundle-and-want-to-autogenerate-enum-list-alter-sqls)

```
$eventManager = new \Doctrine\Common\EventManager();
$eventManager->addEventSubscriber(new \Gusarov112\PhpEnumDoctrine\EventListener\EnumUpdaterSubscriber());

#!/bin/bash ./vendor/bin/doctrine migrations:diff
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~4 days

Total

3

Last Release

2121d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6aa671506ecf4f8a9adf9994926720a4d61bd17afba2645b78704d4f72819d85?d=identicon)[gusarov](/maintainers/gusarov)

---

Top Contributors

[![gusarov112](https://avatars.githubusercontent.com/u/1829821?v=4)](https://github.com/gusarov112 "gusarov112 (3 commits)")

---

Tags

collectiongeneric

### Embed Badge

![Health badge](/badges/gusarov112-php-enum-doctrine/health.svg)

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

###  Alternatives

[phpcollection/phpcollection

General-Purpose Collection Library for PHP

1.0k64.0M34](/packages/phpcollection-phpcollection)[league/period

Time range API for PHP

7335.4M21](/packages/league-period)[loophp/collection

A (memory) friendly, easy, lazy and modular collection class.

745663.8k13](/packages/loophp-collection)[athari/yalinqo

YaLinqo, a LINQ-to-objects library for PHP

4561.2M5](/packages/athari-yalinqo)[lorisleiva/lody

Load files and classes as lazy collections in Laravel.

956.6M9](/packages/lorisleiva-lody)[pragmarx/coollection

Laravel Illuminate collection with objectified properties

943.4M11](/packages/pragmarx-coollection)

PHPackages © 2026

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