PHPackages                             bornfreee/tactician-domain-events-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. bornfreee/tactician-domain-events-bundle

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

bornfreee/tactician-domain-events-bundle
========================================

Bundle to integrate Tactician Domain Events library with Symfony project

0.5.6(5y ago)10138.6k↓50%9[1 PRs](https://github.com/maks-rafalko/tactician-domain-events-bundle/pulls)MITPHPPHP &gt;=5.5CI failing

Since Feb 2Pushed 5y ago4 watchersCompare

[ Source](https://github.com/maks-rafalko/tactician-domain-events-bundle)[ Packagist](https://packagist.org/packages/bornfreee/tactician-domain-events-bundle)[ RSS](/packages/bornfreee-tactician-domain-events-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (15)Used By (0)

Tactician Domain Events Symfony Bundle
======================================

[](#tactician-domain-events-symfony-bundle)

[![Build Status](https://camo.githubusercontent.com/f1e5aee7eab05552ece7da8954b03f1b5c2ffa7a611823c37d1f57d3f32d8fc8/68747470733a2f2f7472617669732d63692e6f72672f626f724e66726565652f74616374696369616e2d646f6d61696e2d6576656e74732d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/borNfreee/tactician-domain-events-bundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9390cd5da9464131871d2e329b4807dd26a1d7867bf746f174ed546fcda561d7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f626f724e66726565652f74616374696369616e2d646f6d61696e2d6576656e74732d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/borNfreee/tactician-domain-events-bundle/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/1c6d5ae230ccc4f9bcbe74ed9377b7fcb6b382199081e06e1b0f26f8a3ef13bc/68747470733a2f2f706f7365722e707567782e6f72672f626f726e66726565652f74616374696369616e2d646f6d61696e2d6576656e74732d62756e646c652f762f737461626c65)](https://packagist.org/packages/bornfreee/tactician-domain-events-bundle)

Symfony Bundle to integrate [Tactician Domain Events library](https://bornfreee.github.io/tactician-domain-events/) with Symfony project

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

[](#installation)

Install via composer

```
composer require bornfreee/tactician-domain-events-bundle
```

Add bundle to `AppKernel.php`:

```
$bundles = [
    // ...
    new \BornFree\TacticianDomainEventBundle\TacticianDomainEventBundle(),
];
```

Configuration
-------------

[](#configuration)

On default event collector `CollectsEventsFromEntities` will be used, but sometimes you might record an event when entity doesn't change so the event is not collected. It's also true when an aggregate root is recording events for its child entities. To collect those events you need to use `CollectsEventsFromAllEntitiesManagedByUnitOfWork`That one collects events from all entities which are managed by Unit of Work. To use it you need to set `collect_from_all_managed_entities` on true:

```
tactician_domain_event:
    collect_from_all_managed_entities: true # it's false on default
```

Usage
-----

[](#usage)

This bundle allows you to automatically have Domain Events dispatched by `EventDispatcher`. It also allows to register event listeners and subscribers as the Symfony Services. You can register as many listeners as you want for each Domain Event.

First, we need to install the Tactician official Bundle to integrate the command bus library:

```
composer require league/tactician-bundle
```

Then we need to configure Middleware to automatically record the Domain Events and dispatch them. We only want to handle the events themselves *after* the command has completely and successfully been handled. So we add the middleware that records the Domain Events *before* the Transaction middleware.

It means that as soon as transaction is completed, the Domain Events will be recorded:

```
tactician:
    commandbus:
        default:
            middleware:
                # other middlewares...
                - tactician_domain_events.middleware.release_recorded_events # make sure to add it before `tactician.middleware.doctrine`
                - tactician.middleware.doctrine
                - tactician.middleware.command_handler
```

### Configuring Event Listeners

[](#configuring-event-listeners)

In order to add event listeners for dispatched Domain Events, we need to define services and the corresponded commands for them:

```
app.listener.send_email:
    class: AppBundle\EventListener\SendEmailAfterUserIsCreatedListener
    tags:
        - { name: tactician.event_listener, event: App\Domain\Events\UserWasCreated }
```

Notice the tag `tactician.event_listener`. The bundle automatically finds all services tagged with this tag and adds the listener to `EventDispatcher`.

By default, event listener shold have public `__invoke` function. If you want to have regular method name, it's possible to it to the service configuration:

```
app.listener.send_email:
    class: AppBundle\EventListener\SendEmailAfterUserIsCreatedListener
    tags:
        - { name: tactician.event_listener, event: App\Domain\Events\UserWasCreated, method: send }
```

This is all configuration you need to start using the Tactician command bus with Domain Events.

Let's have an example where we create a new user and a `UserWasCreated` domain event is dispatched:

```
class User implements ContainsRecordedEvents
{
    use EventRecorderCapabilities;

    public function __construct($name)
    {
        $this->name = $name;

        $this->record(new UserWasCreated($name));
    }

    // ...
}
```

As soon as this `Entity` is successfully created, the `SendEmailAfterUserIsCreatedListener` will be triggered.

### Debugging

[](#debugging)

You can run the `debug:tactician-domain-events` command to get a list of all events with mapped listeners.

License
-------

[](#license)

Copyright (c) 2017, Maks Rafalko

Under MIT license, read LICENSE file.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 61.7% 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 ~97 days

Recently: every ~238 days

Total

14

Last Release

2131d ago

PHP version history (2 changes)0.0.1PHP &gt;=5.4

0.5.0PHP &gt;=5.5

### 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 (29 commits)")[![tomaszhanc](https://avatars.githubusercontent.com/u/7013293?v=4)](https://github.com/tomaszhanc "tomaszhanc (7 commits)")[![thatside-zaraffa](https://avatars.githubusercontent.com/u/25102329?v=4)](https://github.com/thatside-zaraffa "thatside-zaraffa (3 commits)")[![sebidchi](https://avatars.githubusercontent.com/u/2162101?v=4)](https://github.com/sebidchi "sebidchi (2 commits)")[![kruglikdenis](https://avatars.githubusercontent.com/u/9932991?v=4)](https://github.com/kruglikdenis "kruglikdenis (2 commits)")[![uro](https://avatars.githubusercontent.com/u/5208129?v=4)](https://github.com/uro "uro (1 commits)")[![tabbi89](https://avatars.githubusercontent.com/u/5837714?v=4)](https://github.com/tabbi89 "tabbi89 (1 commits)")[![thatside](https://avatars.githubusercontent.com/u/9299200?v=4)](https://github.com/thatside "thatside (1 commits)")[![damienalexandre](https://avatars.githubusercontent.com/u/225704?v=4)](https://github.com/damienalexandre "damienalexandre (1 commits)")

---

Tags

command-busddddomain-driven-designphpsymfony-bundletacticiansymfonybundleeventstacticiandomain

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[pentatrion/vite-bundle

Vite integration for your Symfony app

2755.3M13](/packages/pentatrion-vite-bundle)[spomky-labs/pwa-bundle

Progressive Web App Manifest Generator Bundle for Symfony.

6144.4k1](/packages/spomky-labs-pwa-bundle)[pugx/autocompleter-bundle

Add an autocomplete type to forms

93861.6k3](/packages/pugx-autocompleter-bundle)[sineflow/clamav

ClamAV PHP Client for Symfony

10168.5k](/packages/sineflow-clamav)

PHPackages © 2026

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