PHPackages                             irap/queues - 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. irap/queues

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

irap/queues
===========

Package for queueing because the British love to queue.

2.0.0(8y ago)0888↓100%11MITPHPPHP &gt;=7.0.0

Since Feb 4Pushed 8y ago1 watchersCompare

[ Source](https://github.com/iRAP-software/package-queues)[ Packagist](https://packagist.org/packages/irap/queues)[ Docs](https://github.com/iRAP-software)[ RSS](/packages/irap-queues/feed)WikiDiscussions master Synced 1mo ago

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

Queues
======

[](#queues)

This package was created to make it simple to create queues of tasks, such as for sending [asynchronus MySQL queries](https://github.com/iRAP-software/package-async-query) or [CURL requests](https://github.com/programster/curl-easier).

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

[](#requirements)

- This package was built/tested using PHP 5.6. It may or may not work on earlier versions, but please be aware that [any PHP version lower than 5.6 is deprecated](https://secure.php.net/supported-versions.php).

The Queues
----------

[](#the-queues)

### SerialRunnableQueue

[](#serialrunnablequeue)

Run items one after each other (FIFO), waiting for each one to complete before moving onto the next.

### ParallelRunnableQueue

[](#parallelrunnablequeue)

Run the items in parallel. These items could be executed/completed *in any order*. This is where performance benefits are realized.

### RunnableStack

[](#runnablestack)

Execute items in the same manner as `SerialRunnableQueue` except that instead of being FIFO, items are executed in reverse order with the last item being added being executed first.

Interfaces
----------

[](#interfaces)

In order to use the queus, the objects you put into them need to implement the `RunnableInterface` which simply means the objects have a `run` method that returns true when the task has completed. This method will keep being called by the queue until it returns true. This may seem silly but is necessary for asynchronous requests which may take some time to complete, and thus you need to keep track of the state in the object and return true once you have the result back.

### Queues Within Queues

[](#queues-within-queues)

Due to the fact that all of the queues also implement the `RunnableInterface`, you can create queues of other queues to create any combinations you need. For example, you may have several "tasks" that have to be executed in a certain order, however each of these "tasks" might consist of several hundred "sub-tasks" that can be executed in *any* order. In such a case, you would want to create a `ParallelRunnableQueue` to place each group of subtasks into. Then you would place each of these parallel queues into a single `SerialRunnableQueue` object to make sure the groups get executed in the correct order.

Every queue can take an optional callback in its constructor. This callback is executed whenever the queue is completed/emptied, allowing the developer to run logic only when the queu has finished.

Queues are not a fixed size, you can use the `add` method to add to them whenever you want, including whilst they are running. However, remember that the queu's callback will be invoked each time the queue is depleted.

### Example Usage:

[](#example-usage)

```
...

$asyncQuery1 = new \iRAP\AsyncQuery\AsyncQuery(
    $sql1,
    $queryCallback1,
    $connectionPool
);

$asyncQuery2 = new \iRAP\AsyncQuery\AsyncQuery(
    $sql2,
    $queryCallback2,
    $connectionPool2 # add($asyncQuery1);
$parallelRunnableQueue->add($asyncQuery2);

# Run until the queue has completed all of the tasks.
while ($parallelRunnableQueue->run() !== TRUE)
{
    usleep(1);
}

```

Automated Tests
---------------

[](#automated-tests)

Simply go to the `testing` directory and execute the `main.php` script. All code contributions that add new functionality should provide a relevant test case. It may be a good idea to read through the automated tests to get example usages.

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

2

Last Release

3098d ago

Major Versions

1.0.0 → 2.0.02017-11-14

PHP version history (2 changes)1.0.0PHP &gt;=5.5.0

2.0.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/52783970b96ca5954e3335aacc48870d8db7ee70dad5adaa0170a37e0b028566?d=identicon)[irap\_admin](/maintainers/irap_admin)

---

Top Contributors

[![programster](https://avatars.githubusercontent.com/u/5709838?v=4)](https://github.com/programster "programster (10 commits)")

### Embed Badge

![Health badge](/badges/irap-queues/health.svg)

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

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

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

A generator parser to make streaming parsers simple.

14952.8M16](/packages/amphp-parser)[amphp/serialization

Serialization tools for IPC and data storage in PHP.

13451.1M18](/packages/amphp-serialization)[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

2238.8M170](/packages/react-async)

PHPackages © 2026

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