PHPackages                             dualmedia/symfony-doctrine-event-converter-bundle - 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. dualmedia/symfony-doctrine-event-converter-bundle

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

dualmedia/symfony-doctrine-event-converter-bundle
=================================================

A symfony bundle for creating symfony events out of doctrine changes

3.2.0(1mo ago)11.6k↓100%2[1 issues](https://github.com/dualmediaspzoo/symfony-doctrine-event-converter-bundle/issues)MITPHPPHP ^8.3CI passing

Since Dec 9Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/dualmediaspzoo/symfony-doctrine-event-converter-bundle)[ Packagist](https://packagist.org/packages/dualmedia/symfony-doctrine-event-converter-bundle)[ RSS](/packages/dualmedia-symfony-doctrine-event-converter-bundle/feed)WikiDiscussions master Synced 1mo ago

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

Doctrine Event Dispatcher Bundle
================================

[](#doctrine-event-dispatcher-bundle)

[![Code Coverage](https://camo.githubusercontent.com/8c984abde97874f33a346711794b5da4c2af2e195655e4d6b2816f06c9f2a496/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6465253230436f7665726167652d36392532352d79656c6c6f773f7374796c653d666c6174)](https://camo.githubusercontent.com/8c984abde97874f33a346711794b5da4c2af2e195655e4d6b2816f06c9f2a496/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6465253230436f7665726167652d36392532352d79656c6c6f773f7374796c653d666c6174)[![Packagist Downloads](https://camo.githubusercontent.com/ac3889255394b302c3c1719187e4d055c1bef99210d5adda58ec58ebb98027df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6475616c6d656469612f73796d666f6e792d646f637472696e652d6576656e742d636f6e7665727465722d62756e646c65)](https://packagist.org/packages/dualmedia/symfony-doctrine-event-converter-bundle)

This bundle is meant to convert between doctrine and symfony events seamlessly, as well as allow for creation of sub-events with their own requirements and checks

It allows you to streamline doctrine actions using symfony directly, without need of implementing doctrine's listeners and event logic.

All of the hard work is already done, just declare your entities, implement `IdentifiableInterface` on them, and create an abstract event class.

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

[](#installation)

Simply `composer require dualmedia/symfony-doctrine-event-converter-bundle`

Then add the bundle to your `config/bundles.php` file like so

```
return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    // other bundles ...
    DualMedia\DoctrineEventConverterBundle\DoctrineEventConverterBundle::class => ['all' => true],
];
```

Usage
-----

[](#usage)

### Entity

[](#entity)

Make a Doctrine-managed entity, that also implements the `DualMedia\Common\Interface\IdentifiableInterface`

```
use Doctrine\ORM\Mapping as ORM;
use DualMedia\Common\Interface\IdentifiableInterface;

 #[ORM\Entity]
class Item implements IdentifiableInterface
{
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[ORM\Column(type: 'integer')]
    private ?int $id = null;

    #[ORM\Column(type: 'smallint')]
    private ?int $status = null;

    public function getId()
    {
        return $this->id;
    }

    public function getStatus(): ?int
    {
        return $this->status;
    }

    public function setStatus(
        int $status
    ): self {
        $this->status = $status;

        return $this;
    }
}
```

### Event

[](#event)

Create an event class (not final), and then at some point extend `DualMedia\DoctrineEventConverterBundle\Event\AbstractEntityEvent`, mark this class with your appropriate event annotation, either one of the base ones or SubEvent

```
use DualMedia\DoctrineEventConverterBundle\Attribute\EventEntity;
use DualMedia\DoctrineEventConverterBundle\Attribute\PrePersistEvent;
use DualMedia\DoctrineEventConverterBundle\Event\AbstractEntityEvent;

#[EventEntity(Item::class)] // specifies what Doctrine Entity this event is for, you can use the same event class for multiple
#[PrePersistEvent] // specifies what events will fire
abstract class ItemEvent extends AbstractEntityEvent
{
}
```

The bundle will then automatically generate proxy classes for appropriate events.

Each proxy class starts with [the proxy namespace visible here](src/Proxy/Generator.php) under the `PROXY_NS` constant value.

The following class name will always contain the full namespace of the parent event. This namespace is loaded via the autoloader in the bundle and should not be interacted with in ways other than subscribers and general use.

### SubEvent

[](#subevent)

Let's assume the following scenario: You wish to have an event fired when the status of the `Item` changes from `pending` to `complete`, in this case you'd add the following attribute on your `ItemEvent` (above).

SubEvents can take form of checks which apply to the previous and current state of variable, or only one (from OR to).

### Important

[](#important)

Because of how Doctrine passes changes unfortunately changes to collections are not known at this time.

#### From and To

[](#from-and-to)

The following will generate an `ItemPendingToCompleteEvent` class (under the default proxy namespace).

```
use \DualMedia\DoctrineEventConverterBundle\Attribute\SubEvent;
use \DualMedia\DoctrineEventConverterBundle\Model\Change;

#[SubEvent("PendingToComplete", changes: [new Change('status', ItemStatusEnum::Pending, ItemStatusEnum::Complete)])]
```

Assuming of course the existence of an enum or other value which can be passed to the `Change` model.

More than one change can be required at a time, or *any* change, depending on `SubEvent::$allMode`.

#### From

[](#from)

The following will generate an `ItemFromPendingEvent`.

```
#[SubEvent("FromPending", changes: [new Change('status', ItemStatusEnum::Pending)])]
```

#### To

[](#to)

The following will generate an `ItemCompleteEvent`.

```
#[SubEvent("Complete", changes: [new Change('status', to: ItemStatusEnum::Complete)])]
```

### PHPStan and Psalm issue ignoring

[](#phpstan-and-psalm-issue-ignoring)

Ready-to-use templates are available below to make your lives a bit easier.

Plugins may be provided at a later time, but it's not certain.

#### PHPStan

[](#phpstan)

Either include the file from vendor/dualmedia/symfony-doctrine-event-converter-bundle/phpstan.ignore.dist or use the following settings

```
parameters:
  ignoreErrors:
    - '#Class DualMedia\\DoctrineEventConverterProxy\\[a-zA-Z0-9\\_]+ not found#'
    - '#Parameter \$[a-zA-Z0-9\\_]+ of method [a-zA-Z0-9\\_]+::[a-zA-Z0-9\\_]+\(\) has invalid type DualMedia\\DoctrineEventConverterProxy\\[a-zA-Z0-9\\_]+#'
    - '#Instantiated class DualMedia\\DoctrineEventConverterProxy\\[a-zA-Z0-9\\_]+ not found.#'
    - '#Call to method [a-zA-Z0-9\\_]+\(\) on an unknown class DualMedia\\DoctrineEventConverterProxy\\[a-zA-Z0-9\\_]+.#'

```

I also suggest disabling `reportUnmatchedIgnoredErrors` in your config, but it's not strictly necessary.

#### Psalm

[](#psalm)

This configuration needs to be copied over as psalm does not allow including files.

```

```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance69

Regular maintenance activity

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 92.1% 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 ~62 days

Recently: every ~15 days

Total

20

Last Release

57d ago

Major Versions

1.0.0 → 2.0.02023-01-04

2.4.1 → 3.0.02026-01-15

PHP version history (3 changes)1.0.0PHP ^7.4|^8.1

2.0.0PHP ^8.1

2.4.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/0642c17604cd51622ad504c999eb75ba78e5768bfa998eaa2922366fc90f0302?d=identicon)[pkly](/maintainers/pkly)

---

Top Contributors

[![pkly](https://avatars.githubusercontent.com/u/17160364?v=4)](https://github.com/pkly "pkly (35 commits)")[![barturb](https://avatars.githubusercontent.com/u/16742048?v=4)](https://github.com/barturb "barturb (1 commits)")[![JaWitold](https://avatars.githubusercontent.com/u/47141012?v=4)](https://github.com/JaWitold "JaWitold (1 commits)")[![kamilbarth](https://avatars.githubusercontent.com/u/63015314?v=4)](https://github.com/kamilbarth "kamilbarth (1 commits)")

---

Tags

doctrineormphpsymfonysymfony-bundle

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dualmedia-symfony-doctrine-event-converter-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/dualmedia-symfony-doctrine-event-converter-bundle/health.svg)](https://phpackages.com/packages/dualmedia-symfony-doctrine-event-converter-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

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