Componette

Componette

nepada

nepada / message-bus-doctrine v2.3.1

Doctrine ORM integration for nepada/message-bus

download-cloud-line composer require nepada/message-bus-doctrine

Message Bus Doctrine ORM Extension

Build Status Coverage Status Downloads this Month Latest stable

Installation

Via Composer:

$ composer require nepada/message-bus-doctrine

Usage

Recording domain events inside entities

Make your entities implement Nepada\MessageBusDoctrine\Events\ContainsRecordedEvents (e.g. by using Nepada\MessageBusDoctrine\Events\PrivateEventRecorder trait) and record domain events inside the entities. The events will be automatically collected and dispatched on flush.

Transaction handling

TransactionMiddleware wraps the command handling into a database transaction. All changes made by lower layers are automatically flushed and commited, or rolled back on error.

It is highly recommended to use PreventOuterTransactionMiddleware to ensure there is no outer database transaction started outside of the message bus stack. Not doing so might lead to unwanted behavior such as dispatching and processing events before the changes made in command handler were actually persisted.

Clearing entity manager

Use ClearEntityManagerMiddleware to clear entity manager before and/or after the message is handled. Note: Entity manager will not be cleared when inside active transaction, i.e. the middleware order is important.

Credits

Event recording idea and parts of its implementation are based on simple-bus/doctrine-orm-bridge by Matthias Noback, Cliff Odijk, Ruud Kamphuis.

  • v2.3.1 2.3.1

    • PHP 8.4 compatibility
  • v2.3.0 2.3.0

    • Drop Doctrine ORM <2.13 support
    • Add Doctrine ORM 3.x support
    • Add nepada/message-bus 3.x support
  • v2.2.0 2.2.0

    • Drop support for PHP <8.1
    • PHP 8.3 compatibility
  • v2.1.2 2.1.2

    • PHP 8.2 compatibility
  • v2.1.1 2.1.1

    • Restrict maximum supported PHP version explicitly in composer.json
    • Allow doctrine/persistence 3.x
  • v2.1.0 2.1.0

    • PHP 8.1 compatibility.
  • v2.0.2 2.0.2

    • Fix edge case with Doctrine identity map containing null
  • v2.0.1 2.0.1

    • PHP 8.0 compatiblity.
  • v2.0.0 2.0.0

    • Initial public release.
Componette Componette felix@nette.org