PHPackages                             ez-php/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. [Framework](/categories/framework)
4. /
5. ez-php/queue

ActiveLibrary[Framework](/categories/framework)

ez-php/queue
============

Async job queue for the ez-php framework — database and Redis drivers, Worker, and queue:work command

1.11.1(1mo ago)01251MITPHPPHP ^8.5CI passing

Since Mar 18Pushed 1mo agoCompare

[ Source](https://github.com/ez-php/queue)[ Packagist](https://packagist.org/packages/ez-php/queue)[ Docs](https://github.com/ez-php/queue)[ RSS](/packages/ez-php-queue/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (21)Versions (38)Used By (1)

ez-php/queue
============

[](#ez-phpqueue)

Async job queue for the [ez-php framework](https://github.com/ez-php) — database and Redis drivers, a Worker, and a `queue:work` console command.

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

[](#requirements)

- PHP 8.5+
- ext-pdo
- ez-php/contracts 0.\*
- ez-php/console 0.\*
- ext-redis (Redis driver only)

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

[](#installation)

```
composer require ez-php/queue
```

Setup
-----

[](#setup)

Register the service provider:

```
$app->register(\EzPhp\Queue\QueueServiceProvider::class);
```

Add the worker command to the CLI:

```
$app->registerCommand(\EzPhp\Queue\Console\WorkCommand::class);
```

Add `config/queue.php` to your application:

```
return [
    'driver' => env('QUEUE_DRIVER', 'database'),  // 'database' | 'redis'
    'redis'  => [
        'host'     => env('REDIS_HOST', '127.0.0.1'),
        'port'     => (int) env('REDIS_PORT', 6379),
        'database' => (int) env('REDIS_DATABASE', 0),
    ],
];
```

Defining Jobs
-------------

[](#defining-jobs)

```
use EzPhp\Queue\Job;

final class SendWelcomeEmail extends Job
{
    protected string $queue    = 'emails';
    protected int    $maxTries = 5;

    public function __construct(private readonly string $email) {}

    public function handle(): void
    {
        // send the email ...
    }

    public function fail(\Throwable $exception): void
    {
        // log or notify on permanent failure
    }
}
```

Dispatching Jobs
----------------

[](#dispatching-jobs)

```
use EzPhp\Contracts\QueueInterface;

$queue = $app->make(QueueInterface::class);
$queue->push(new SendWelcomeEmail('alice@example.com'));
```

Delay a job by setting `$delay` (seconds):

```
final class ProcessReport extends Job
{
    protected int $delay = 60; // available after 60 seconds
    // ...
}
```

> **Note:** The Redis driver does not enforce `$delay`. Use the database driver for delayed job delivery.

Running the Worker
------------------

[](#running-the-worker)

```
php ez queue:work                  # process 'default' queue, sleep 3s on empty
php ez queue:work emails           # process 'emails' queue
php ez queue:work emails --sleep=5 # custom sleep interval
php ez queue:work --max-jobs=100   # stop after 100 jobs (useful for cron-based workers)
```

Drivers
-------

[](#drivers)

### Database Driver (default)

[](#database-driver-default)

Stores jobs in a `jobs` table and failed jobs in `failed_jobs`. Both tables are created automatically. Requires a configured `DatabaseInterface` in the container.

Supports delayed delivery via `available_at` column.

### Redis Driver

[](#redis-driver)

Uses `ext-redis`. Jobs are pushed to `queues:{name}` (RPUSH) and consumed via LPOP (FIFO). Failed jobs are appended to `queues:failed:{name}`.

Delayed delivery is **not** enforced — jobs are queued immediately regardless of `$delay`.

Failed jobs
-----------

[](#failed-jobs)

The database driver stores permanently failed jobs and exposes management commands:

```
php ez queue:failed list            # list all failed jobs
php ez queue:failed retry {id}      # re-queue a failed job
php ez queue:failed delete {id}     # delete a failed job record
php ez queue:failed flush           # delete all failed jobs
```

Monitoring
----------

[](#monitoring)

```
php ez queue:monitor                        # snapshot of queue depths + failed count
php ez queue:monitor --queues=emails,sms    # specific queues
php ez queue:monitor --watch=5              # refresh every 5 seconds
```

Scheduling
----------

[](#scheduling)

Register recurring jobs in a service provider's `boot()`:

```
$scheduler = $app->make(\EzPhp\Queue\Scheduling\Scheduler::class);

$scheduler->job(SendDailyReport::class)->daily();
$scheduler->job(PruneTokens::class)->hourly();
$scheduler->job(SyncData::class)->everyMinutes(15);
$scheduler->job(CustomJob::class)->cron('30 6 * * 1');
```

Run `queue:schedule` every minute via system cron:

```
* * * * * php /var/www/html/ez queue:schedule

```

Classes
-------

[](#classes)

ClassDescription`Job`Abstract base class for all jobs`Worker`Pops and executes jobs; handles retries and permanent failures`QueueServiceProvider`Registers `QueueInterface` and `Worker` with the DI container`Driver\DatabaseDriver`PDO-backed driver with atomic pop, delayed delivery, and `FailedJobRepositoryInterface``Driver\RedisDriver`Redis-backed driver via ext-redis`FailedJobRepositoryInterface`Contract for failed-job stores: `all()`, `retry()`, `forget()`, `flush()``Scheduling\Scheduler`Registry of recurring jobs; evaluates due tasks by cron expression`Scheduling\ScheduledTask`Fluent builder: `daily()`, `hourly()`, `everyMinutes()`, `cron()``Console\WorkCommand``queue:work` CLI command`Console\MonitorCommand``queue:monitor` CLI command`Console\FailedCommand``queue:failed` CLI command`Console\ScheduleRunCommand``queue:schedule` CLI command`QueueException`Base exception for queue errorsSetup (standalone development)
------------------------------

[](#setup-standalone-development)

```
cp .env.example .env
./start.sh
```

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance91

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 90.2% 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 ~1 days

Total

37

Last Release

44d ago

Major Versions

0.9.3 → 1.0.02026-03-24

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/122030400?v=4)[AU9500](/maintainers/AU9500)[@AU9500](https://github.com/AU9500)

---

Top Contributors

[![AU9500](https://avatars.githubusercontent.com/u/122030400?v=4)](https://github.com/AU9500 "AU9500 (119 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (13 commits)")

---

Tags

phpasyncframeworkqueuejobsworkerez-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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