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

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

webfiori/queue
==============

A lightweight job queue library for PHP with file-based storage.

v1.0.0(1mo ago)0661↓77.8%[2 issues](https://github.com/WebFiori/queue/issues)[1 PRs](https://github.com/WebFiori/queue/pulls)1MITPHPPHP &gt;=8.1CI passing

Since May 29Pushed 1mo agoCompare

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

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

WebFiori Queue
==============

[](#webfiori-queue)

A lightweight job queue library for PHP with file-based storage, priority ordering, and retry logic.

 [![](https://github.com/WebFiori/queue/actions/workflows/php84.yaml/badge.svg?branch=main)](https://github.com/WebFiori/queue/actions) [ ![](https://camo.githubusercontent.com/252f1cb6de6935b41f3a93282c25b812db0f8e17f205920da33b1e1c446e4ba0/68747470733a2f2f636f6465636f762e696f2f67682f57656246696f72692f71756575652f6272616e63682f6d61696e2f67726170682f62616467652e737667) ](https://codecov.io/gh/WebFiori/queue) [ ![](https://camo.githubusercontent.com/c5c048cb1aa0161f6dfbf8399ebd8b8845eb1155335ac578b190549c8dd44b1f/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d57656246696f72695f7175657565266d65747269633d616c6572745f737461747573) ](https://sonarcloud.io/dashboard?id=WebFiori_queue) [ ![](https://camo.githubusercontent.com/ab0820568aa7d5e3c93197de524df620969cb455eafcf4b2eca0509578c19b07/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f57656246696f72692f71756575652e7376673f6c6162656c3d6c6174657374) ](https://github.com/WebFiori/queue/releases) [ ![](https://camo.githubusercontent.com/29866ea212322172481828c4c67eab9735af73a17e17755ac0b7a5b56912c43e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656266696f72692f71756575653f636f6c6f723d6c696768742d677265656e) ](https://packagist.org/packages/webfiori/queue)

Supported PHP Versions
----------------------

[](#supported-php-versions)

This library requires **PHP 8.1 or higher**.

Build Status[![](https://github.com/WebFiori/queue/actions/workflows/php81.yaml/badge.svg?branch=main)](https://github.com/WebFiori/queue/actions/workflows/php81.yaml)[![](https://github.com/WebFiori/queue/actions/workflows/php82.yaml/badge.svg?branch=main)](https://github.com/WebFiori/queue/actions/workflows/php82.yaml)[![](https://github.com/WebFiori/queue/actions/workflows/php83.yaml/badge.svg?branch=main)](https://github.com/WebFiori/queue/actions/workflows/php83.yaml)[![](https://github.com/WebFiori/queue/actions/workflows/php84.yaml/badge.svg?branch=main)](https://github.com/WebFiori/queue/actions/workflows/php84.yaml)[![](https://github.com/WebFiori/queue/actions/workflows/php85.yaml/badge.svg?branch=main)](https://github.com/WebFiori/queue/actions/workflows/php85.yaml)Features
--------

[](#features)

- **Job interface** — define units of work with retry configuration
- **FileQueueStorage** — file-based backend, zero infrastructure needed
- **Priority ordering** — higher priority jobs processed first
- **Delayed dispatch** — schedule jobs to run after a delay
- **Automatic retry** — failed jobs re-queued with configurable backoff
- **Failed job tracking** — inspect and retry failed jobs
- **Static facade** (`QueueFacade`) for quick usage without DI
- **Zero dependencies** — requires only PHP 8.1+

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

[](#installation)

```
composer require webfiori/queue
```

Usage
-----

[](#usage)

### Define a Job

[](#define-a-job)

```
use WebFiori\Queue\Job;

class SendEmailJob implements Job {
    public function __construct(
        private string $to,
        private string $subject
    ) {}

    public function handle(): void {
        // Send the email
        mail($this->to, $this->subject, 'Hello!');
    }

    public function getMaxAttempts(): int {
        return 3;
    }

    public function getRetryDelaySeconds(): int {
        return 60; // wait 60s × attempt number before retry
    }
}
```

### Dispatch and Process

[](#dispatch-and-process)

```
use WebFiori\Queue\FileQueueStorage;
use WebFiori\Queue\Queue;

$queue = new Queue(new FileQueueStorage('/path/to/storage'));

// Dispatch jobs
$queue->dispatch(new SendEmailJob('user@example.com', 'Welcome!'));
$queue->dispatch(new SendEmailJob('vip@example.com', 'Priority!'), priority: 10);
$queue->dispatch(new SendEmailJob('later@example.com', 'Delayed'), delaySeconds: 300);

// Process pending jobs (call this from a scheduler or worker)
$processed = $queue->process(limit: 50);
```

### Static Facade

[](#static-facade)

```
use WebFiori\Queue\QueueFacade;

QueueFacade::dispatch(new SendEmailJob('user@example.com', 'Hello'));
QueueFacade::process();
```

### Failed Jobs

[](#failed-jobs)

```
// View failed jobs
$failed = $queue->getFailed();

// Retry a specific failed job
$queue->retry($failed[0]['id']);

// Clear all failed jobs
$queue->flush();
```

API
---

[](#api)

### `Job` (interface)

[](#job-interface)

MethodDescription`handle(): void`Execute the job logic`getMaxAttempts(): int`Maximum retry attempts`getRetryDelaySeconds(): int`Base delay between retries (multiplied by attempt number)### `Queue`

[](#queue)

MethodDescription`__construct(QueueStorage $storage)`Create queue with storage backend`dispatch(Job $job, int $priority = 0, int $delaySeconds = 0): string`Add job to queue, returns job ID`process(int $limit = 10): int`Process pending jobs, returns count processed`retry(string $id): void`Retry a failed job`getPendingCount(): int`Number of pending jobs`getFailed(): array`All failed jobs`flush(): void`Remove all failed jobs`getStorage(): QueueStorage`Get the storage backend### `QueueStorage` (interface)

[](#queuestorage-interface)

MethodDescription`push(string $id, string $payload, int $priority, int $availableAt): void`Store a job`pop(int $limit): array`Retrieve available jobs`markComplete(string $id): void`Remove completed job`markFailed(string $id, string $reason, int $attempts): void`Move to failed`setAttempts(string $id, int $attempts): void`Update attempt count`retry(string $id): void`Move failed job back to pending`getPendingCount(): int`Count pending jobs`getFailed(): array`Get all failed jobs`flush(): void`Clear failed jobs### `QueueFacade`

[](#queuefacade)

Static wrapper. Same methods as `Queue` plus `getInstance()`, `setInstance()`, `reset()`.

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance89

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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

Unknown

Total

1

Last Release

57d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c25e43acaa22b4fb758a710b69c2ab75947a6642925e3bec9c98196b1f2a433?d=identicon)[usernane](/maintainers/usernane)

---

Top Contributors

[![usernane](https://avatars.githubusercontent.com/u/12120015?v=4)](https://github.com/usernane "usernane (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.6M31](/packages/league-geotools)[illuminate/bus

The Illuminate Bus package.

6046.3M586](/packages/illuminate-bus)[brave-sir-robin/amqphp

AMQP 0.9.1 Protocol Implementation in pure PHP

7932.8k](/packages/brave-sir-robin-amqphp)[belvg/module-sqs

N/A

1544.6k](/packages/belvg-module-sqs)[mayconbordin/l5-stomp-queue

Stomp Queue Driver for Laravel 5

121.1k](/packages/mayconbordin-l5-stomp-queue)

PHPackages © 2026

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