PHPackages                             dayemsiddiqui/laravel-saga - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. dayemsiddiqui/laravel-saga

ActiveLibrary[Queues &amp; Workers](/categories/queues)

dayemsiddiqui/laravel-saga
==========================

This is my package laravel-saga

2.0.4(10mo ago)0429[4 PRs](https://github.com/dayemsiddiqui/laravel-saga/pulls)MITPHPPHP ^8.2CI passing

Since Jul 10Pushed 1mo agoCompare

[ Source](https://github.com/dayemsiddiqui/laravel-saga)[ Packagist](https://packagist.org/packages/dayemsiddiqui/laravel-saga)[ Docs](https://github.com/dayemsiddiqui/laravel-saga)[ GitHub Sponsors]()[ RSS](/packages/dayemsiddiqui-laravel-saga/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (17)Versions (19)Used By (0)

This is my package laravel-saga
===============================

[](#this-is-my-package-laravel-saga)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fd16585cc2921e01b906a31979e079bd16655b7a0ee577046f4e8dff4ca9a6b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646179656d73696464697175692f6c61726176656c2d736167612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dayemsiddiqui/laravel-saga)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7529dcf850241dc55cad63d3a51947dbfef4f5fe29ef287b265b03e2a2d7b82b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f646179656d73696464697175692f6c61726176656c2d736167612f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/dayemsiddiqui/laravel-saga/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/c4c4f365e9642ed20b3954c086f0731cd4b79a63869eb00095557305d27069d2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f646179656d73696464697175692f6c61726176656c2d736167612f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/dayemsiddiqui/laravel-saga/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/c91877236bc2ee99837c74480380065d158a8d951abce08582b6fefa44c0f0f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646179656d73696464697175692f6c61726176656c2d736167612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dayemsiddiqui/laravel-saga)

The Laravel Saga package helps you manage complex workflows by breaking them down into a series of sequential steps. It orchestrates these steps as a 'saga', executing them in order and tracking the progress of each one in your database. This gives you a clear and persistent overview of your long-running processes, like an e-commerce order flow or a video processing pipeline.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/79ecc9fb9a503b4976ebe088c05aca41bebf25c00935da9c5c95e6bd45c69024/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d736167612e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-saga)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require dayemsiddiqui/laravel-saga
php artisan saga:install
```

And then you can run:

```
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="saga-config"
```

This is the contents of the published config file:

```
return [
];
```

Optionally, you can publish the views using

```
php artisan vendor:publish --tag="saga-views"
```

Usage
-----

[](#usage)

### 1. Create Your Saga Steps

[](#1-create-your-saga-steps)

Each step in your saga should extend the `SagaStep` abstract class and implement the `run()` method:

```
use dayemsiddiqui\Saga\SagaStep;

class FirstStep extends SagaStep
{
    protected function run(): void
    {
        // Your business logic here
        // You can access $this->context to share data between steps
        $this->context()->set('foo', 'bar');
    }
}

class SecondStep extends SagaStep
{
    protected function run(): void
    {
        // Access data from previous steps
        $foo = $this->context()->get('foo');
        // More business logic...
    }
}
```

### 2. Run a Saga

[](#2-run-a-saga)

You can chain your steps and dispatch the saga like this:

```
use dayemsiddiqui\Saga\Saga;

// Optionally, use the facade: use Saga;

$saga = Saga::named('My Example Saga')
    ->chain([
        FirstStep::class,
        SecondStep::class,
    ])
    ->dispatch();
```

- Each step will be executed in order.
- The saga and each step’s status will be tracked in the database.
- Use the `context()` helper to share data between steps.

### Testing your Sagas

[](#testing-your-sagas)

This package provides a fake implementation of the `Saga` facade that you can use in your tests to avoid actually dispatching the jobs.

To use it, call `Saga::fake()` at the beginning of your test.

```
use dayemsiddiqui\Saga\Saga;
use Pest\Laravel\test;

test('example saga is dispatched', function () {
    Saga::fake();

    // Run the code that dispatches your saga
    // ...

    Saga::assertDispatched('My Example Saga');
});
```

#### `assertDispatched(string $name, ?array $steps = null)`

[](#assertdispatchedstring-name-array-steps--null)

Asserts that a saga with the given name was dispatched. You can also optionally assert that it was dispatched with a specific chain of steps.

```
Saga::assertDispatched('My Example Saga', [
    FirstStep::class,
    SecondStep::class,
]);
```

#### `assertNotDispatched(string $name)`

[](#assertnotdispatchedstring-name)

Asserts that a saga with the given name was not dispatched.

```
Saga::assertNotDispatched('Some Other Saga');
```

#### `assertDispatchedCount(int $count)`

[](#assertdispatchedcountint-count)

Asserts that a specific number of sagas were dispatched.

```
Saga::assertDispatchedCount(1);
```

Running Tests
-------------

[](#running-tests)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Dayem Siddiqui](https://github.com/dayemsiddiqui)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance75

Regular maintenance activity

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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.

###  Release Activity

Cadence

Every ~0 days

Total

14

Last Release

305d ago

Major Versions

1.0.9 → 2.0.02025-07-10

PHP version history (2 changes)v1.0.0PHP ^8.4

2.0.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![dayemsiddiqui](https://avatars.githubusercontent.com/u/9693176?v=4)](https://github.com/dayemsiddiqui "dayemsiddiqui (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

laravelDayem Siddiquilaravel-saga

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/dayemsiddiqui-laravel-saga/health.svg)

```
[![Health](https://phpackages.com/badges/dayemsiddiqui-laravel-saga/health.svg)](https://phpackages.com/packages/dayemsiddiqui-laravel-saga)
```

###  Alternatives

[croustibat/filament-jobs-monitor

Background Jobs monitoring like Horizon for all drivers for FilamentPHP

254255.2k6](/packages/croustibat-filament-jobs-monitor)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

3786.5k](/packages/harris21-laravel-fuse)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)

PHPackages © 2026

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