PHPackages                             shipsaas/laravel-priority-queue - 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/laravel-priority-queue

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

shipsaas/laravel-priority-queue
===============================

Priority Queue implementation for your Laravel Applications

1.1.0(2y ago)492.8k3MITPHPPHP ^8.2|^8.3

Since Apr 2Pushed 2y ago1 watchersCompare

[ Source](https://github.com/shipsaas/laravel-priority-queue)[ Packagist](https://packagist.org/packages/shipsaas/laravel-priority-queue)[ RSS](/packages/shipsaas-laravel-priority-queue/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (7)Versions (5)Used By (0)

ShipSaaS - Laravel Priority Queue Driver
========================================

[](#shipsaas---laravel-priority-queue-driver)

[![Latest Version](https://camo.githubusercontent.com/85867736eaf0320f87530d437574fe4023b6759c51c5e607afd0f0b0e804c6b0/687474703a2f2f706f7365722e707567782e6f72672f73686970736161732f6c61726176656c2d7072696f726974792d71756575652f76)](https://packagist.org/packages/shipsaas/laravel-priority-queue)[![Total Downloads](https://camo.githubusercontent.com/4a956df6822e93ff6dde008e48df990284ac68e38d7b68053210cb309bdecfde/687474703a2f2f706f7365722e707567782e6f72672f73686970736161732f6c61726176656c2d7072696f726974792d71756575652f646f776e6c6f616473)](https://packagist.org/packages/shipsaas/laravel-priority-queue)[![codecov](https://camo.githubusercontent.com/bb5e297f52bff740e2686c1f476a104191491d64a6ef3d8c0b7c3fa7b00fa744/68747470733a2f2f636f6465636f762e696f2f67682f73686970736161732f6c61726176656c2d7072696f726974792d71756575652f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d5633484f4f5231324841)](https://codecov.io/gh/shipsaas/laravel-priority-queue)[![Build & Test](https://github.com/shipsaas/laravel-priority-queue/actions/workflows/build.yml/badge.svg)](https://github.com/shipsaas/laravel-priority-queue/actions/workflows/build.yml)[![Build & Test (Laravel 10, 11)](https://github.com/shipsaas/laravel-priority-queue/actions/workflows/build-laravel.yml/badge.svg)](https://github.com/shipsaas/laravel-priority-queue/actions/workflows/build-laravel.yml)

A simple Priority Queue Driver for your Laravel Applications to serve your priority messages and makes users happy 🔋.

With the famous Repository Pattern of Laravel, Priority Queue Driver is easily get injected into Laravel's Lifecycle without any hassle/hurdle.

We can use built-in artisan command `php artisan queue:work` 😎.

Supports
--------

[](#supports)

- Laravel 11 (supports by default)
- Laravel 10 (supports until Laravel drops the bug fixes at [August 6th, 2024](https://laravel.com/docs/11.x/releases))
- PHP 8.2 &amp; 8.3
- Any database that Laravel supported.

Architecture Diagram
--------------------

[](#architecture-diagram)

[![Seth Phat - Laravel Priority Queue](https://camo.githubusercontent.com/c0dd9b81b4a574682058fc8c4d9706f5ca6392b6b5fdb3c8144b24dd4b3f682b/68747470733a2f2f692e696d6775722e636f6d2f48384f454d68512e706e67)](https://camo.githubusercontent.com/c0dd9b81b4a574682058fc8c4d9706f5ca6392b6b5fdb3c8144b24dd4b3f682b/68747470733a2f2f692e696d6775722e636f6d2f48384f454d68512e706e67)

### Why Priority Queue Driver use Database?

[](#why-priority-queue-driver-use-database)

- Everybody knows Database (MySQL, PgSQL, etc) 👀.
- Easy and simple to implement ❤️.
- Utilize the `ORDER BY` and `INDEX` for fast queue msgs pop process. Faster than any other stuff 🔥.
- Highest visibility (you can view the jobs and their data in DB) ⭐️.
- Highest flexibility (you can change the weight directly in DB to unblock important msgs) 💰.
- No extra tool involved. Just Laravel 🥰.

Install Laravel Priority Queue
------------------------------

[](#install-laravel-priority-queue)

```
composer require shipsaas/laravel-priority-queue
```

### One-Time Setup

[](#one-time-setup)

Export and run the migration (one-time). We don't load migration by default just in case you want to customize the migration schema 😎.

```
php artisan vendor:publish --tag=priority-queue-migrations
php artisan migrate
```

Open `config/queue.php` and add this to the `connections` array:

```
'connections' => [
    // ... a lot of connections above
    // then our lovely guy here
    'database-priority' => [
        'driver' => 'database-priority',
        'connection' => 'mysql',
        'table' => 'priority_jobs',
        'queue' => 'default',
        'retry_after' => 90,
        'after_commit' => false, // or true, depends on your need
    ],
],
```

Scale/Reliability Consideration
-------------------------------

[](#scalereliability-consideration)

It is recommended to use a different database connection (eg `mysql_secondary`) to avoid the worker processes ramming your primary database.

Usage
-----

[](#usage)

### The Job Weight

[](#the-job-weight)

The default job weight is **500**.

You can define a hardcoded weight for your job by using the `$jobWeight` property.

```
class SendEmail implements ShouldQueue
{
    public int $jobWeight = 500;
}
```

Or if you want to calculate the job weight on runtime, you can use the `UseJobPrioritization` trait:

```
use ShipSaasPriorityQueue\Traits\UseJobPrioritization;

class SendEmail implements ShouldQueue
{
    use UseJobPrioritization;

    public function getJobWeight() : int
    {
        return $this->user->isUsingProPlan()
            ? 1000
            : 500;
    }
}
```

### Dispatch the Queue

[](#dispatch-the-queue)

You can use the normal Dispatcher or Queue Facade,... to dispatch the Queue Msgs

### As primary queue

[](#as-primary-queue)

```
QUEUE_CONNECTION=database-priority
```

And you're ready to roll.

### As secondary queue

[](#as-secondary-queue)

Specify the `database-priority` connection when dispatching a queue msg.

```
// use Dispatcher
SendEmail::dispatch($user, $emailContent)
    ->onConnection('database-priority');

// use Queue Facade
use Illuminate\Support\Facades\Queue;

Queue::connection('database-priority')
    ->push(new SendEmail($user, $emailContent));
```

I get that you guys might don't want to explicitly put the connection name. Alternatively, you can do this:

```
class SendEmail implements ShouldQueue
{
    // first option
    public $connection = 'database-priority';

    public function __construct()
    {
        // second option
        $this->onConnection('database-priority');
    }
}
```

Run The Queue Worker
--------------------

[](#run-the-queue-worker)

Nothing different from the Laravel Documentation 😎. Just need to include the `database-priority` driver.

```
php artisan queue:work database-priority

# Extra win, priority on topic
php artisan queue:work database-priority --queue=custom
```

Testing
-------

[](#testing)

Run `composer test` 😆

Available Tests:

- Unit Testing
- Integration Testing against MySQL and `queue:work` command

Contributors
------------

[](#contributors)

- Seth Phat

Contributions &amp; Support the Project
---------------------------------------

[](#contributions--support-the-project)

Feel free to submit any PR, please follow PSR-1/PSR-12 coding conventions and unit test is a must.

If this package is helpful, please give it a ⭐️⭐️⭐️. Thank you!

License
-------

[](#license)

MIT License

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

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

Total

2

Last Release

803d ago

PHP version history (2 changes)1.0.0PHP ^8.1|^8.2

1.1.0PHP ^8.2|^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23478115?v=4)[Seth Phat](/maintainers/sethsandaru)[@sethsandaru](https://github.com/sethsandaru)

---

Top Contributors

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

---

Tags

laravellaravel-frameworklaravel-packagephppriority-queuequeuelaravellaravel-librarylaravel-queuelaravel priority queue

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/shipsaas-laravel-priority-queue/health.svg)

```
[![Health](https://phpackages.com/badges/shipsaas-laravel-priority-queue/health.svg)](https://phpackages.com/packages/shipsaas-laravel-priority-queue)
```

###  Alternatives

[laravel/octane

Supercharge your Laravel application's performance.

4.0k26.6M218](/packages/laravel-octane)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11223.5M33](/packages/anourvalar-eloquent-serialize)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)[mpbarlow/laravel-queue-debouncer

A wrapper job for debouncing other queue jobs.

63825.7k1](/packages/mpbarlow-laravel-queue-debouncer)[api-platform/laravel

API Platform support for Laravel

58170.4k13](/packages/api-platform-laravel)

PHPackages © 2026

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