PHPackages                             shipsaas/safe-dispatcher - 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. shipsaas/safe-dispatcher

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

shipsaas/safe-dispatcher
========================

Ensure your Queue msg is tracked and retryable when failed to dispatch.

1.2.0(3y ago)30171MITPHPPHP ^8.1|^8.2

Since Feb 14Pushed 3y ago2 watchersCompare

[ Source](https://github.com/shipsaas/safe-dispatcher)[ Packagist](https://packagist.org/packages/shipsaas/safe-dispatcher)[ RSS](/packages/shipsaas-safe-dispatcher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (6)Used By (0)

Laravel Safe Dispatcher for Queues
==================================

[](#laravel-safe-dispatcher-for-queues)

[![Latest Version](https://camo.githubusercontent.com/42d46a121239a4bf3c05aa74121b9014f2bb6639dd7ebb7d05f5e61f98fa3514/687474703a2f2f706f7365722e707567782e6f72672f73686970736161732f736166652d646973706174636865722f76)](https://packagist.org/packages/shipsaas/safe-dispatcher)[![Total Downloads](https://camo.githubusercontent.com/9c487fca460272fde29279948b4ccd4f0b15d1f9c65c1bfcfbc8b2143fc82109/687474703a2f2f706f7365722e707567782e6f72672f73686970736161732f736166652d646973706174636865722f646f776e6c6f616473)](https://packagist.org/packages/shipsaas/safe-dispatcher)[![codecov](https://camo.githubusercontent.com/b70a02aeb94bc43977a5b7e523f9b00660079c2724a136abea86f6b728779928/68747470733a2f2f636f6465636f762e696f2f67682f73686970736161732f736166652d646973706174636865722f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d464c5655343132435549)](https://codecov.io/gh/shipsaas/safe-dispatcher)[![Build & Test](https://github.com/shipsaas/safe-dispatcher/actions/workflows/build.yml/badge.svg)](https://github.com/shipsaas/safe-dispatcher/actions/workflows/build.yml)[![Build & Test (Laravel 9, 10)](https://github.com/shipsaas/safe-dispatcher/actions/workflows/build-laravel.yml/badge.svg)](https://github.com/shipsaas/safe-dispatcher/actions/workflows/build-laravel.yml)[![Try Install Package (Laravel 9 & 10)](https://github.com/shipsaas/safe-dispatcher/actions/workflows/try-installation.yml/badge.svg)](https://github.com/shipsaas/safe-dispatcher/actions/workflows/try-installation.yml)

For Laravel, it has the Queues feature, all cool and easy to use, right?

But what if it **fails to dispatch a job**? Then you have no idea for:

- What was the data inside the msg?
- What was the error? Traces?
- How to resend the Queue msg with minimal effort?

Then it will cost you a lot of time to check the log, sentry issues, create retry command,... Awful, IKR?

Worries no more, SafeDispatcher got your back. Check out how it works below.

Documentation:

- This README
- [APIs](./docs/APIs.md)
- [GUI](./docs/GUI.md)

How SafeDispatcher works?
-------------------------

[](#how-safedispatcher-works)

[![How does Laravel SafeDispatcher works?](./docs/SafeDispatcher.png)](./docs/SafeDispatcher.png)

SafeDispatcher will:

- Store the failed to dispatch msgs.
- Retry them on demand.
- You can even change the connection driver or the name on retry.
    - Would really come in handy when you have a `SQSException` (size &gt; 256kb), then you can resend using redis/database driver.
- Ensure that your processing/flow is still working properly (no 500 server error from HTTP or exceptions from queue worker).
    - Super useful &amp; helpful for mission-critical apps.

Requirements
------------

[](#requirements)

- Laravel 9+ &amp; 10+
- PHP 8.1 &amp; 8.2

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

[](#installation)

```
composer require shipsaas/safe-dispatcher
```

Usage
-----

[](#usage)

### Dependency Injection

[](#dependency-injection)

```
use SaasSafeDispatcher\Bus\SafeDispatcher;

class RegisterService
{
    public function __construct(public SafeDispatcher $dispatcher) {}

    public function register(): void
    {
        $user = User::create();

        $job = new SendEmailToRegisteredUser($user);
        $this->dispatcher->dispatch($job);
    }
}
```

### Use Trait for your Job

[](#use-trait-for-your-job)

```
use SaasSafeDispatcher\Traits\SafeDispatchable;

class SendEmailToRegisteredUser implements ShouldQueue
{
    use SafeDispatchable;
}

SendEmailToRegisteredUser::safeDispatch($user);
```

### Quick Helper Functions

[](#quick-helper-functions)

```
safeDispatch(new SendEmailToRegisteredUser($user));

safeDispatch(() => echo('Hello'));

safeDispatchSync(new SendEmailToRegisteredUser($user));
```

### Cover Queue Facade (v1.2.0+)

[](#cover-queue-facade-v120)

```
use SaasSafeDispatcher\Services\SafeQueue;

SafeQueue::prepareFor(new Job())
    ->push('high'); # Push to "high" queue name
```

Learn more [Cover Queue Facade](./docs/QueueFacade.md)

Notes
-----

[](#notes)

- SafeDispatcher hasn't supported with batching &amp; chaining.
    - Alternatively, you can do normal `::safeDispatch` and after finish your job, dispatch another,...
- SafeDispatcher considers the `sync` Queue as a Queue Msg.
    - Therefore, if the handling fails, Queue Msg will be stored too.
- SafeDispatcher ships some helpful APIs too, check it out: [APIs](./docs/APIs.md)

Tests
-----

[](#tests)

SafeDispatcher is not only have normal Unit Testing but also Integration Test (interacting with MySQL for DB and Redis for Queue).

We're planning to add other queue drivers too (database or SQS).

To run the test, hit this:

```
composer test
```

Contribute to the project
-------------------------

[](#contribute-to-the-project)

- All changes must follow PSR-1 / PSR-12 coding conventions.
- Unit testing is a must, cover things as much as you can.

### Maintainers &amp; Contributors

[](#maintainers--contributors)

- Seth Phat

Join me 😉

This library is useful?
-----------------------

[](#this-library-is-useful)

Thank you, please give it a ⭐️⭐️⭐️ to support the project.

Don't forget to share with your friends &amp; colleagues 🚀

License
-------

[](#license)

Copyright © by ShipSaaS 2023 - Under MIT License.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~33 days

Total

3

Last Release

1116d ago

### Community

Maintainers

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

---

Top Contributors

[![sethsandaru](https://avatars.githubusercontent.com/u/23478115?v=4)](https://github.com/sethsandaru "sethsandaru (35 commits)")

---

Tags

laravellaravel-frameworklaravel-packagephpqueuelaravel-librarylaravel safe dispatcherlaravel safe dispatch ensure your Queue Job Msgs are totally tracked and resendable

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/shipsaas-safe-dispatcher/health.svg)

```
[![Health](https://phpackages.com/badges/shipsaas-safe-dispatcher/health.svg)](https://phpackages.com/packages/shipsaas-safe-dispatcher)
```

###  Alternatives

[mpbarlow/laravel-queue-debouncer

A wrapper job for debouncing other queue jobs.

63714.4k1](/packages/mpbarlow-laravel-queue-debouncer)[eyewitness/eye

Eyewitness.io client for Laravel 5 applications

116151.8k](/packages/eyewitness-eye)[therezor/laravel-transactional-jobs

Submit laravel jobs inside transaction. Cancel job after rollback. Proceed after successful commit.

44449.4k](/packages/therezor-laravel-transactional-jobs)[convenia/pigeon

3233.0k](/packages/convenia-pigeon)[baklysystems/laravel-chat-messenger

Laravel chat package

121.8k](/packages/baklysystems-laravel-chat-messenger)

PHPackages © 2026

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