brzuchal/saga

Saga Pattern Implementation

Maintainers

👁 brzuchal

Package info

github.com/brzuchal/saga

pkg:composer/brzuchal/saga

Statistics

Installs: 978

Dependents: 1

Suggesters: 0

Stars: 2

Open Issues: 1

1.x-dev 2023-03-21 11:00 UTC

Requires

Suggests

  • symfony/expression-language: Allows to evaluate association values from a message using a notation allowing to compile and evaluate expressions
  • symfony/property-access: Allows to evaluate association values from a message object or embeded array using a simple string notation

Provides

None

Conflicts

None

Replaces

None

MIT e231fdc99e3d07892dfe0f2d6bd93ada6f127ffe

  • Michał Brzuchalski <michal.brzuchalski.woop@gmail.com>

This package is auto-updated.

Last update: 2026-06-15 07:37:37 UTC


README

Install

composer require brzuchal/saga

Usage

namespace App;

use App\Events\OrderCreated;
use Brzuchal\Saga\Mapping\Saga;
use Brzuchal\Saga\Mapping\SagaMessageHandler;
use Brzuchal\Saga\Mapping\SagaStart;

#[Saga]
class OrderProcessing
{
 #[SagaStart,SagaMessageHandler(associationKey: 'orderId', property: 'id')]
 public function whenCreated(OrderCreated $event): void
 {
 // ...
 }
}

Configuration

use App\OrderProcessing;
use App\Events\OrderCreated;
use Brzuchal\Saga\Mapping\AttributeMappingDriver;
use Brzuchal\Saga\Mapping\SagaMetadataFactory;
use Brzuchal\Saga\Repository\SimpleSagaRepositoryFactory;
use Brzuchal\Saga\SagaManager;
use Brzuchal\Saga\Store\InMemorySagaStore;

$repositoryFactory = new SimpleSagaRepositoryFactory(
 new InMemorySagaStore(), 
 new SagaMetadataFactory([new AttributeMappingDriver()]),
);

$manager = new SagaManager($repositoryFactory->create(OrderProcessing::class));
$manager(new OrderCreated());