PHPackages                             nixphp/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. nixphp/queue

ActiveNixphp-plugin[Queues &amp; Workers](/categories/queues)

nixphp/queue
============

NixPHP Queue Plugin for asynchronous jobs.

v0.1.3(4mo ago)01001MITPHPPHP &gt;=8.3CI passing

Since Dec 5Pushed 4mo agoCompare

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

READMEChangelog (4)Dependencies (4)Versions (9)Used By (1)

[![Logo](https://camo.githubusercontent.com/075b2860e9651b98b8c190a8296595c54cff6900890d9e494f31131145e98a6f/68747470733a2f2f6e69787068702e6769746875622e696f2f646f63732f6173736574732f6e69787068702d6c6f676f2d736d616c6c2d7371756172652e706e67)](https://camo.githubusercontent.com/075b2860e9651b98b8c190a8296595c54cff6900890d9e494f31131145e98a6f/68747470733a2f2f6e69787068702e6769746875622e696f2f646f63732f6173736574732f6e69787068702d6c6f676f2d736d616c6c2d7371756172652e706e67)

[![NixPHP Queue Plugin](https://github.com/nixphp/queue/actions/workflows/php.yml/badge.svg)](https://github.com/nixphp/queue/actions/workflows/php.yml)

[← Back to NixPHP](https://github.com/nixphp/framework)

---

nixphp/queue
============

[](#nixphpqueue)

> **Minimalistic queueing for NixPHP – file-based, simple, and extendable.**

This plugin provides a lightweight job queue system with CLI worker support and no external dependencies by default.

> 🧩 Part of the official NixPHP plugin collection.
> Use it when you want to delay tasks, run background jobs, or decouple logic – without setting up Redis or RabbitMQ.

---

📦 Features
----------

[](#-features)

- File-based queue driver (no DB or Redis required)
- CLI worker for background processing
- Logical **channels** (single queue, multiple job streams)
- One-off async execution (`pushAndRun()`)
- Deadletter handling **per channel**
- Retry support (channel-aware)
- Fully PSR-4 and event-loop friendly
- Extendable: write your own driver for SQLite, Redis, etc.

---

📥 Installation
--------------

[](#-installation)

```
composer require nixphp/queue
```

That’s it. The plugin will be autoloaded automatically.

---

Usage
-----

[](#usage)

### Queue a job (default channel)

[](#queue-a-job-default-channel)

Create a job class that implements the `QueueJobInterface`:

```
use NixPHP\Queue\QueueJobInterface;

class SendWelcomeEmail implements QueueJobInterface
{
    public function __construct(protected array $payload) {}

    public function execute(): void
    {
        // Send your email here
    }
}
```

Push it to the default queue:

```
queue()->push(SendWelcomeEmail::class, ['email' => 'user@example.com']);
```

---

### 🧵 Using channels

[](#-using-channels)

Channels are **logical job streams** inside the same queue backend. They allow you to separate workloads (e.g. `emails`, `mcp_out`, `notifications`) without running multiple queue systems.

Push a job to a specific channel:

```
queue('emails')->push(SendWelcomeEmail::class, [
    'email' => 'user@example.com'
]);
```

Internally, channels are handled by the queue driver.

---

### ⚡ Fire-and-forget (async)

[](#-fire-and-forget-async)

For **one-off asynchronous execution**, use:

```
queue('emails')->pushAndRun(
    SendWelcomeEmail::class,
    ['email' => 'user@example.com']
);
```

This queues the job and immediately runs it in the background via a short-lived CLI process, automatically passing the channel to the worker.

Ideal for emails, logging, notifications, or side-effects that should not block a request.

---

Start the worker
----------------

[](#start-the-worker)

Run the consuming worker and listen on the default channel:

```
./bin/nix queue:consume
```

Listen on a specific channel:

```
./bin/nix queue:consume --channel=emails
```

Listen on multiple channels (checked in order):

```
./bin/nix queue:consume --channels=default,emails,mcp_out
```

Run a single job only:

```
./bin/nix queue:consume --once
```

> 🔹 `--once` is also used internally by `pushAndRun()`.

---

Deadletter &amp; Retry (channel-aware)
--------------------------------------

[](#deadletter--retry-channel-aware)

If a job fails too often, it is written to a **deadletter directory per channel**:

```
/path/to/app/storage/queue/deadletter//.job

```

Retry failed jobs for the default channel:

```
./bin/nix queue:retry-failed
```

Retry failed jobs for a specific channel:

```
./bin/nix queue:retry-failed --channel=emails
```

By default, retried jobs are removed from the deadletter queue. Use `--keep` to retain them:

```
./bin/nix queue:retry-failed --channel=emails --keep
```

---

🧠 Drivers
---------

[](#-drivers)

The queue system is driver-based. Included drivers:

DriverDescriptionSuitable for`FileDriver`Stores jobs as `.job` files in foldersLocal use, no DB needed*(planned)*SQLite / Redis / othersLarger or shared setupsTo register a custom driver, configure it in your `bootstrap.php`:

```
use NixPHP\Queue\Core\Queue;
use NixPHP\Queue\Drivers\FileDriver;

app()->container()->set(Queue::class, function () {
    return new Queue(
        new FileDriver(
            app()->getBasePath() . FileDriver::DEFAULT_QUEUE_PATH,
            app()->getBasePath() . FileDriver::DEFAULT_DEADLETTER_PATH
        )
    );
});
```

> 📁 The file paths are only relevant for `FileDriver`.

---

🛠️ Supervisor example (optional)
--------------------------------

[](#️-supervisor-example-optional)

To run the worker persistently in production, use [Supervisor](http://supervisord.org):

```
[program:nixphp-worker]
command=php bin/nix queue:consume --channels=default,emails
directory=/path/to/your/app
autostart=true
autorestart=true
stderr_logfile=/var/log/nixphp/worker.err.log
stdout_logfile=/var/log/nixphp/worker.out.log
```

---

✅ Requirements
--------------

[](#-requirements)

- `nixphp/framework` ^0.1.0
- `nixphp/cli` ^0.1.0 (required for worker commands)

---

📄 License
---------

[](#-license)

MIT License.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance77

Regular maintenance activity

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

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

Total

4

Last Release

127d ago

### Community

Maintainers

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

---

Top Contributors

[![FloKnapp](https://avatars.githubusercontent.com/u/3774820?v=4)](https://github.com/FloKnapp "FloKnapp (33 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nixphp-queue/health.svg)

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

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.3M26](/packages/league-geotools)[enqueue/enqueue

Message Queue Library

19820.0M56](/packages/enqueue-enqueue)[deliciousbrains/wp-background-processing

WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks.

1.1k409.8k6](/packages/deliciousbrains-wp-background-processing)[react/async

Async utilities and fibers for ReactPHP

2228.8M171](/packages/react-async)[react/promise-stream

The missing link between Promise-land and Stream-land for ReactPHP

11512.9M45](/packages/react-promise-stream)[illuminate/bus

The Illuminate Bus package.

6043.8M409](/packages/illuminate-bus)

PHPackages © 2026

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