PHPackages                             bornfree/tactician-doctrine-domain-events - 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. bornfree/tactician-doctrine-domain-events

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

bornfree/tactician-doctrine-domain-events
=========================================

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

0.4.0(8y ago)7150.6k↓55.6%1MITPHPPHP &gt;=5.4

Since Jan 22Pushed 7y ago3 watchersCompare

[ Source](https://github.com/maks-rafalko/tactician-doctrine-domain-events)[ Packagist](https://packagist.org/packages/bornfree/tactician-doctrine-domain-events)[ RSS](/packages/bornfree-tactician-doctrine-domain-events/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (8)Dependencies (3)Versions (9)Used By (1)

Tactician Domain Events - Doctrine Bridge
=========================================

[](#tactician-domain-events---doctrine-bridge)

[![Build Status](https://camo.githubusercontent.com/2b1e14435ed50e3879e067d92b3b3afbc83fa21e74daa41a185d449acf33e69a/68747470733a2f2f7472617669732d63692e6f72672f626f724e66726565652f74616374696369616e2d646f637472696e652d646f6d61696e2d6576656e74732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/borNfreee/tactician-doctrine-domain-events)[![codecov](https://camo.githubusercontent.com/005defb4371a177ef3f75ab8b0c91b256c2f7e17b80163290a28c7674de4bfea/68747470733a2f2f636f6465636f762e696f2f67682f626f724e66726565652f74616374696369616e2d646f637472696e652d646f6d61696e2d6576656e74732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/borNfreee/tactician-doctrine-domain-events)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ca63e02c018f9da0446bb9e21665ec912b4488e081b09114f10b515b4c92d4a2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f626f724e66726565652f74616374696369616e2d646f6d61696e2d6576656e74732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/borNfreee/tactician-domain-events/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/07579e31368fe79c31b078b2e0826decb0020584da056624c054622f4a8bfff7/68747470733a2f2f706f7365722e707567782e6f72672f626f726e667265652f74616374696369616e2d646f637472696e652d646f6d61696e2d6576656e74732f762f737461626c65)](https://packagist.org/packages/bornfree/tactician-doctrine-domain-events)

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

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

[](#installation)

Install via composer

```
composer require bornfree/tactician-doctrine-domain-events
```

Usage
-----

[](#usage)

Using the [events recorder facilities](https://maks-rafalko.github.io/tactician-domain-events/doc/domain_events.html#record-events-in-entity) you can let Doctrine ORM collect domain events and subsequently let the `EventDispatcher` handle them.

Make sure that your entities implement the `ContainsRecordedMessages` interface. Use the `EventRecorderCapabilities` trait from [Tactician Domain Events](https://maks-rafalko.github.io/tactician-domain-events) library to conveniently record events from inside the entity:

```
use BornFree\TacticianDomainEvent\Recorder\ContainsRecordedEvents;
use BornFree\TacticianDomainEvent\Recorder\EventRecorderCapabilities;

class Task implements ContainsRecordedMessages
{
    use EventRecorderCapabilities;

    public function __construct($name)
    {
        $this->record(new TaskWasCreated($name));
    }
}
```

Then set up the *event recorder* for Doctrine entities:

```
use BornFree\TacticianDoctrineDomainEvent\EventListener\CollectsEventsFromEntities;

$eventRecorder = new CollectsEventsFromEntities();

$entityManager->getConnection()->getEventManager()->addEventSubscriber($eventRecorder);
```

> ##### Syfmony integration
>
> [](#syfmony-integration)
>
> This listener will be registered automatically with Symfony, see the [documentation](https://maks-rafalko.github.io/tactician-domain-events-bundle)

The event recorder will loop over all the entities that were involved in the last database transaction and collect their internally recorded events.

After a database transaction was completed successfully these events should be handled by the `EventDispatcher`. This is done by a specialized middleware, which should be added to the command bus *before* the middleware that is responsible for handling the transaction.

```
use League\Tactician\CommandBus;
use League\Tactician\Doctrine\ORM\TransactionMiddleware;
use namespace BornFree\TacticianDomainEvent\Middleware\ReleaseRecordedEventsMiddleware;

// see the previous sections about $eventRecorder and $eventDispatcher
$releaseRecordedEventsMiddleware = new ReleaseRecordedEventsMiddleware($eventRecorder, $eventDispatcher);

$commandBus = new CommandBus(
    [
        $releaseRecordedEventsMiddleware, // it should be before transaction middleware
        $transactionMiddleware,
        $commandHandlerMiddleware
    ]
);
```

License
-------

[](#license)

Copyright (c) 2017, Maks Rafalko

Under MIT license, read LICENSE file.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.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 ~43 days

Recently: every ~72 days

Total

8

Last Release

3149d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0196ce472ed16a55b72aa7f9f9956bc6e68fa519abf975caffc9fcb5fa320df?d=identicon)[borN\_free](/maintainers/borN_free)

---

Top Contributors

[![maks-rafalko](https://avatars.githubusercontent.com/u/3725595?v=4)](https://github.com/maks-rafalko "maks-rafalko (18 commits)")[![tomaszhanc](https://avatars.githubusercontent.com/u/7013293?v=4)](https://github.com/tomaszhanc "tomaszhanc (3 commits)")[![mrafalkoitr](https://avatars.githubusercontent.com/u/8488734?v=4)](https://github.com/mrafalkoitr "mrafalkoitr (2 commits)")

---

Tags

command-busddddoctrine-bridgedomain-driven-designsimple-bustactician

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bornfree-tactician-doctrine-domain-events/health.svg)

```
[![Health](https://phpackages.com/badges/bornfree-tactician-doctrine-domain-events/health.svg)](https://phpackages.com/packages/bornfree-tactician-doctrine-domain-events)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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