PHPackages                             ormin/mapping-domain-events-handler - 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. ormin/mapping-domain-events-handler

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

ormin/mapping-domain-events-handler
===================================

Set of classes allowing you to grasp the benefits of using and persisting domain events while still persisting state changes into your system

2111PHP

Since Nov 24Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Ormin/mapping-domain-events-handler)[ Packagist](https://packagist.org/packages/ormin/mapping-domain-events-handler)[ RSS](/packages/ormin-mapping-domain-events-handler/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Mapping domain events handler
=============================

[](#mapping-domain-events-handler)

Allows you to map the domain events to atomic calls, which will persist the desired event's state change. Useful if you're not having/not able to implement Event Sourcing into your system, but you want to make use of Domain Events as a primary source of change within your code

To install it, use Composer:

```
$ composer require --dev ormin/mapping-domain-events-handler:dev-master

```

To use it, inject the EventBasedRepository class into your domain repository implementation and pass the AggregateRoot for it to save

```
class Member implements AggregateRoot { ... }

class DBALMemberRepository implements MemberRepository {

	private $repository;

	public function __construct(EventBasedRepository $repository) {
		$this->repository = $repository;
	}

	public function save(Member $aggregateRoot) {
		$this->repository->save($aggregateRoot);
	}

}

```

You instantiate one EventBasedRepository per aggregate, with an event store implementation. This project ships with a SimpleMappingEventStore, which will map the events to the POPO objects' calls. Create the POPO handler object, and instantiate SimpleMappingEventStore with it injected as a constructor parameter:

```
class UserAddedAProductToBasket { ... }

class DBALMappingMemberEventStore {

	public function handleUserAddedAProductToBasket() {
		//Handle persisting of state of what happened within the aggregate
		$statement = $this->connection->prepare("INSERT INTO ...");
	}

}

class User extends EventSourcedAggregateRoot {

	public function addToBasket(Product $product) {
		$this->apply(new UserAddedAProductToBasket($product));
	}

	public function handleUserAddedAProductToBasket(UserAddedAProductToBasket $event) {
		//Handle the event within the aggregate
	}

	//When this aggregate will be sent for saving, its uncommitted events' will be sent to event store and mapped to the DBALMappingMemberEventStore::handleUserAddedAProductToBasket()

}

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d839dac1c6ed45790cd09aed53ea9817e361d905efd142ba11a267c5a3901b7b?d=identicon)[AlexFortune](/maintainers/AlexFortune)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/ormin-mapping-domain-events-handler/health.svg)

```
[![Health](https://phpackages.com/badges/ormin-mapping-domain-events-handler/health.svg)](https://phpackages.com/packages/ormin-mapping-domain-events-handler)
```

###  Alternatives

[amenadiel/jpgraph

Composer Friendly, full refactor of JpGraph, library to make graphs and charts

1532.4M7](/packages/amenadiel-jpgraph)

PHPackages © 2026

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