brzuchal/saga
Laravel package implementing the Saga pattern for coordinating long-running, distributed workflows. Helps model multi-step processes with compensating actions, track saga state, and handle failures/retries so complex business transactions stay consistent across services.
composer require brzuchal/saga
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
{
// ...
}
}
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());
How can I help you explore Laravel packages today?