PHPackages                             b7s/laravel-queue-flow - 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. b7s/laravel-queue-flow

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

b7s/laravel-queue-flow
======================

A fluent Laravel Queue wrapper, simplifying queue management without creating separate Job classes

v0.1.1(6mo ago)42MITPHPPHP &gt;=8.2

Since Oct 29Pushed 6mo agoCompare

[ Source](https://github.com/b7s/laravel-queue-flow)[ Packagist](https://packagist.org/packages/b7s/laravel-queue-flow)[ RSS](/packages/b7s-laravel-queue-flow/feed)WikiDiscussions main Synced 1mo ago

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

 [![Queue Flow](docs/art/logo.webp)](docs/art/logo.webp)

Laravel Queue Flow
==================

[](#laravel-queue-flow)

A [Laravel Queue](https://laravel.com/docs/12.x/queues) wrapper system, simplifying queue management without creating separate Job classes.

Features
--------

[](#features)

- 🚀 **Simple API**: No need to create separate Job classes
- 🔒 **Type-safe**: Full PHP 8.2+ type hints
- 🎯 **Fluent Interface**: Chain methods for easy configuration
- 🔐 **Encryption Support**: Built-in job encryption
- 🔄 **Unique Jobs**: Prevent duplicate job execution
- ⚡ **Rate Limiting**: Control job execution rate
- 🎨 **Flexible**: Support for delays, connections, and queues
- 🧪 **Tests**: Pest tests included

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

[](#requirements)

- PHP 8.2 or higher
- Laravel 11.0 or higher

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

[](#installation)

Install the package via Composer:

```
composer require b7s/laravel-queue-flow
```

The service provider will be automatically registered.

### Publish Configuration (Optional)

[](#publish-configuration-optional)

```
php artisan vendor:publish --tag=queue-flow-config
```

This package has some configurations, but it doesn't override the default Laravel settings, which you can modify in `config/queue.php`.

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Using global helper function `qflow`:

```
// Dispatch automatically One item
qflow(fn () => $this->doOtherThing());

// Dispatch automatically multiple items with array of closures
qflow([
    fn () => $this->doOtherThing(),
    fn () => $this->doMoreThings(),
    // ...
]);

// Dispatch manually (set autoDispatch to false) after configuration
qflow(fn () => $this->doOtherThing(), autoDispatch: false)
    ->onQueue('high-priority')
    ->shouldBeUnique()
    ->shouldBeEncrypted()
    ->rateLimited('default')
    ->onFailure(function () {
        // Your logic here
    })
    ->dispatch();

// Dispatch multiple items with returns a Collection of PendingDispatch objects,
// then, apply middleware to each dispatch
qflow([
    fn () => $this->callExternalApi(),
    fn () => $this->callExternalApi(),
])
// Apply middleware to each dispatch
->each(fn ($dispatch) => $dispatch->through([new \Illuminate\Queue\Middleware\RateLimited('api-calls')]));
```

### Auto-dispatch on Destruction

[](#auto-dispatch-on-destruction)

The queue will automatically dispatch when the object is destroyed if a callback was added:

> Know more about the `dispatch()` return value [here](docs/DISPATCH_RETURN.md).

Using the `Queue` instance directly:

```
