componenta/cqrs-transaction-cycle

Cycle Database transaction middleware for Componenta CQRS commands

Maintainers

Package info

github.com/componenta/cqrs-transaction-cycle

pkg:composer/componenta/cqrs-transaction-cycle

Transparency log

Statistics

Installs: 10

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.0.2 2026-08-16 17:50 UTC

This package is auto-updated.

Last update: 2026-08-21 01:32:29 UTC


README

Cycle Database transaction middleware for componenta/cqrs commands. The current package supports CQRS 2.x, 3.x, and the current CQRS v4 line.

composer require componenta/cqrs-transaction-cycle

The package has no ConfigProvider. TransactionMiddleware is constructor-autowireable; register Cycle\Database\DatabaseInterface in your container and add Componenta\CQRS\Command\Middleware\TransactionMiddleware to ConfigKey::COMMAND_MIDDLEWARES where command transactions are required.

Middleware ordering is application configuration. With retry outside transaction:

RetryMiddleware
  TransactionMiddleware
    handler

each retry attempt gets its own begin -> rollback/commit boundary. With transaction outside retry:

TransactionMiddleware
  RetryMiddleware
    handler

all retry attempts run inside one surrounding transaction. The package does not reject either topology; applications choose the transaction scope they need and should account for how failed attempts affect that scope.

Policy placement is likewise application-defined. Putting policy outside transaction avoids opening a transaction for commands that authorization rejects; putting policy inside transaction deliberately includes authorization in the transaction boundary.

Example:

use Componenta\CQRS\Command\Middleware\TransactionMiddleware;
use Componenta\CQRS\ConfigKey;

return [
    ConfigKey::COMMAND_MIDDLEWARES => [
        TransactionMiddleware::class,
    ],
];