PHPackages                             fyre/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. [Caching](/categories/caching)
4. /
5. fyre/queue

ActiveLibrary[Caching](/categories/caching)

fyre/queue
==========

A Queue library.

v3.2.3(11mo ago)0863MITPHP

Since Jun 8Pushed 11mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (8)Versions (25)Used By (3)

FyreQueue
=========

[](#fyrequeue)

**FyreQueue** is a free, open-source queue library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
- [Queues](#queues)
    - [Redis](#redis)
- [Workers](#workers)
- [Messages](#messages)
- [Commands](#commands)
    - [Stats](#stats)
    - [Worker](#worker)

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

[](#installation)

**Using Composer**

```
composer require fyre/queue

```

In PHP:

```
use Fyre\Queue\QueueManager;
```

Basic Usage
-----------

[](#basic-usage)

- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).
- `$config` is a [*Config*](https://github.com/elusivecodes/FyreConfig).

```
$queueManager = new QueueManager($container, $config);
```

Default configuration options will be resolved from the "*Queue*" key in the [*Config*](https://github.com/elusivecodes/FyreConfig).

**Autoloading**

It is recommended to bind the *QueueManager* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.

```
$container->singleton(QueueManager::class);
```

Any dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$queueManager = $container->use(QueueManager::class);
```

Methods
-------

[](#methods)

**Build**

Build a [*Queue*](#queues).

- `$options` is an array containing configuration options.

```
$queue = $queueManager->build($options);
```

[*Queue*](#queues) dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).

**Clear**

Clear all instances and configs.

```
$queueManager->clear();
```

**Get Config**

Set a [*Queue*](#queues) config.

- `$key` is a string representing the [*Queue*](#queues) key.

```
$config = $queueManager->getConfig($key);
```

Alternatively, if the `$key` argument is omitted an array containing all configurations will be returned.

```
$config = $queueManager->getConfig();
```

**Has Config**

Determine whether a [*Queue*](#queues) config exists.

- `$key` is a string representing the [*Queue*](#queues) key, and will default to `QueueManager::DEFAULT`.

```
$hasConfig = $queueManager->hasConfig($key);
```

**Is Loaded**

Determine whether a [*Queue*](#queues) instance is loaded.

- `$key` is a string representing the [*Queue*](#queues) key, and will default to `QueueManager::DEFAULT`.

```
$isLoaded = $queueManager->isLoaded($key);
```

**Push**

Push a job to a [*Queue*](#queues).

- `$className` is a string representing the job class.
- `$arguments` is an array containing arguments that will be passed to the job.
- `$options` is an array containing options for the [*Message*](#messages).
    - `config` is a string representing the configuration key, and will default to `QueueManager::DEFAULT`.
    - `queue` is a string representing the [queue](#queues) name, and will default to `QueueManager::DEFAULT`.
    - `method` is a string representing the class method, and will default to "*run*".
    - `delay` is a number representing the number of seconds before the job should run, and will default to 0.
    - `expires` is a number representing the number of seconds after which the job will expire, and will default to 0.
    - `retry` is a boolean indicating whether the job should be retried if it fails, and will default to *true*.
    - `maxRetries` is a number indicating the maximum number of times the job should be retried, and will default to *5*.
    - `unique` is a boolean indicating whether the job should be unique, and will default to *false*.

```
$queueManager->push($className, $arguments, $options);
```

Job dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).

**Set Config**

Set the [*Queue*](#queues) config.

- `$key` is a string representing the [*Queue*](#queues) key.
- `$options` is an array containing configuration options.

```
$queueManager->setConfig($key, $options);
```

**Unload**

Unload a [*Queue*](#queues).

- `$key` is a string representing the [*Queue*](#queues) key, and will default to `QueueManager::DEFAULT`.

```
$queueManager->unload($key);
```

**Use**

Load a shared [*Queue*](#queues) instance.

- `$key` is a string representing the [*Queue*](#queues) key, and will default to *"default"*.

```
$queue = $queueManager->use($key);
```

[*Queue*](#queues) dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).

Queues
------

[](#queues)

You can load a specific queue by specifying the `className` option of the `$options` variable above.

Custom queues can be created by extending `\Fyre\Queue\Queue`, ensuring all below methods are implemented.

**Clear**

Clear all items from the queue.

- `$queueName` is a string representing the queue name, and will default to `QueueManager::DEFAULT`.

```
$queue->clear($queueName);
```

**Complete**

Mark a job as completed.

- `$message` is a [*Message*](#message).

```
$queue->complete($message);
```

**Fail**

Mark a job as failed.

- `$message` is a [*Message*](#message).

```
$queue->fail($message);
```

**Pop**

Pop the last item off the queue.

- `$queueName` is a string representing the queue name.

```
$message = $queue->pop($queueName);
```

**Push**

Push a job onto the queue.

- `$message` is a [*Message*](#message).

```
$queue->push($message);
```

**Queues**

Get all the active queues.

```
$queues = $queue->queues();
```

**Reset**

Reset the queue statistics.

- `$queueName` is a string representing the queue name, and will default to `QueueManager::DEFAULT`.

```
$queue->reset($queueName);
```

**Stats**

Get the statistics for a queue.

- `$queueName` is a string representing the queue name, and will default to `QueueManager::DEFAULT`.

```
$stats = $queue->stats($queueName);
```

### Redis

[](#redis)

The Redis queue can be loaded using custom configuration.

- `$options` is an array containing configuration options.
    - `className` must be set to `\Fyre\Queue\Handlers\RedisQueue`.
    - `host` is a string representing the Redis host, and will default to "*127.0.0.1*".
    - `password` is a string representing the Redis password
    - `port` is a number indicating the Redis port, and will default to *6379*.
    - `database` is a string representing the Redis database.
    - `timeout` is a number indicating the connection timeout.
    - `persist` is a boolean indicating whether to use a persistent connection, and will default to *true*.
    - `tls` is a boolean indicating whether to use a tls connection, and will default to *true*.
    - `ssl` is an array containing SSL options.
        - `key` is a string representing the path to the key file.
        - `cert` is a string representing the path to the certificate file.
        - `ca` is a string representing the path to the certificate authority file.

```
$container->use(Config::class)->set('Queue.redis', $options);
```

Workers
-------

[](#workers)

Workers are long running tasks that will consume and execute jobs from the queue.

```
use Fyre\Queue\Worker;
```

- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).
- `$queueManager` is a *QueueManager*.
- `$eventManager` is an [*EventManager*](https://github.com/elusivecodes/FyreEvent).
- `$options` is an array containing configuration options.
    - `config` is a string representing the configuration key, and will default to `QueueManager::DEFAULT`.
    - `queue` is a string representing the queue name, and will default to `QueueManager::DEFAULT`.
    - `maxJobs` is a number representing the maximum number of jobs to execute, and will default to 0.
    - `maxRuntime` is a number representing the maximum number of seconds the worker should run, and will default to 0.
    - `rest` is a number representing the number of microseconds to rest after processing a job, and will default to *10000*.
    - `sleep` is a number representing the number of microseconds to sleep if no jobs are in the queue, and will default to *100000*.

```
$worker = new Worker($container, $queueManager, $eventManager, $options);
```

**Run**

Run the worker.

```
$worker->run();
```

Messages
--------

[](#messages)

Messages are used internally to pass data between the [*Queue*](#queues) and [*Worker*](#workers).

```
use Fyre\Queue\Message;
```

- `$options` is an array containing options for the message.
    - `className` is a string representing the job class.
    - `arguments` is an array containing arguments that will be passed to the job.
    - `config` is a string representing the configuration key, and will default to `QueueManager::DEFAULT`.
    - `queue` is a string representing the queue name, and will default to `QueueManager::DEFAULT`.
    - `method` is a string representing the class method, and will default to "*run*".
    - `delay` is a number representing the number of seconds before the job should run, and will default to 0.
    - `expires` is a number representing the number of seconds after which the job will expire, and will default to 0.
    - `retry` is a boolean indicating whether the job should be retried if it fails, and will default to *true*.
    - `maxRetries` is a number indicating the maximum number of times the job should be retried, and will default to *5*.
    - `unique` is a boolean indicating whether the job should be unique, and will default to *false*.

```
$message = new Message($options);
```

**Get After**

Get the timestamp when the message can be sent.

```
$after = $message->getTimestamp();
```

**Get Config**

Get the message config.

```
$config = $message->getConfig();
```

**Get Hash**

Get the message hash.

```
$hash = $message->getHash();
```

**Get Queue**

Get the message queue.

```
$queueName = $message->getQueue();
```

**Is Expired**

Determine whether the message has expired.

```
$isExpired = $message->isExpired();
```

**Is Ready**

Determine whether the message is ready.

```
$isReady = $message->isReady();
```

**Is Unique**

Determine whether the message is unique.

```
$isUnique = $message->isUnique();
```

**Is Valid**

Determine whether the message is valid.

```
$isValid = $message->isValid();
```

**Should Retry**

Determine whether the message should be retried.

```
$shouldretry = $message->shouldRetry();
```

Commands
--------

[](#commands)

### Stats

[](#stats)

Display stats for the queue.

- `--config` is a the configuration key, and will default to `QueueManager::DEFAULT`.
- `--queue` is a the [queue](#queues) name, and will default to `QueueManager::DEFAULT`.

```
$commandRunner->run('queue:stats', ['--config', 'default', '--queue', 'default']);
```

### Worker

[](#worker)

Start a background queue worker.

- `--config` is a the configuration key, and will default to `QueueManager::DEFAULT`.
- `--queue` is a the [queue](#queues) name, and will default to `QueueManager::DEFAULT`.
- `--max-jobs` is the maximum number of jobs to execute, and will default to 0.
- `--max-runtime` is the maximum number of seconds the worker should run, and will default to 0.

```
$commandRunner->run('queue:worker', ['--config', 'default', '--queue', 'default', '--max-jobs', '99', '--max-runtime', '60']);
```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance50

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity58

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

Recently: every ~25 days

Total

24

Last Release

355d ago

Major Versions

v1.0 → v2.02023-07-26

v2.0.11 → v3.02024-11-09

### Community

Maintainers

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

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (24 commits)")

---

Tags

phpqueueredisworker

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-httpcache

HttpCache for Laravel

502404.4k10](/packages/barryvdh-laravel-httpcache)

PHPackages © 2026

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