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

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

chipslays/queue
===============

Simple implement queue processing in PHP.

1.1.2(4y ago)1101MITPHP

Since Apr 25Pushed 4y ago1 watchersCompare

[ Source](https://github.com/chipslays/queue)[ Packagist](https://packagist.org/packages/chipslays/queue)[ RSS](/packages/chipslays-queue/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (7)Dependencies (1)Versions (8)Used By (0)

🛒 Queue
=======

[](#-queue)

[![Packagist Version](https://camo.githubusercontent.com/6908ff6e338a3cbf50ef9e5990c4085428282516a795024b772cdaaf476447a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63686970736c6179732f7175657565)](https://camo.githubusercontent.com/6908ff6e338a3cbf50ef9e5990c4085428282516a795024b772cdaaf476447a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63686970736c6179732f7175657565)[![GitHub](https://camo.githubusercontent.com/105092aad77b5048d5cb87a67ecb55cc16ba6298321e2de6ff0cff206236be5e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f63686970736c6179732f7175657565)](https://camo.githubusercontent.com/105092aad77b5048d5cb87a67ecb55cc16ba6298321e2de6ff0cff206236be5e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f63686970736c6179732f7175657565)

Simple implement queue processing in PHP.

Installation
============

[](#installation)

```
$ composer require chipslays/queue
```

Usage
=====

[](#usage)

### Client

[](#client)

We push something to queue.

```
use Chipslays\Queue\Queue;
use Chipslays\Queue\Drivers\File;

require __DIR__ . '/vendor/autoload.php';

$driver = new File([
    'storage' => __DIR__ . '/storage/',
]);

$queue = new Queue($driver);
$queue->add('payment', ['user_id' => 1, 'amount' => 10]);
```

### Worker

[](#worker)

We have worker, who get value from queue and starts processing.

 **worker.php**```
use Chipslays\Queue\Queue;
use Chipslays\Queue\Drivers\File;

require __DIR__ . '/vendor/autoload.php';

$driver = new File([
    'storage' => __DIR__ . '/storage/',
]);

$queue = new Queue($driver);

while (true) {
    if (!$item = $queue->next('payment')) {
        continue;
    }

    echo 'channel: ' . $item->getChannel() . PHP_EOL;
    echo 'id: ' . $item->getId() . PHP_EOL;
    echo 'data: ' . print_r($item->getData(), true) . PHP_EOL;

    // also can be getting by magic getter: $item->id, $item->channel, $item->data
}
```

### Cron

[](#cron)

Or instead loop worker, we can use a cron job.

 **cron-worker.php**```
use Chipslays\Queue\Queue;
use Chipslays\Queue\Drivers\File;

require __DIR__ . '/vendor/autoload.php';

$driver = new File([
    'storage' => __DIR__ . '/storage/',
]);

$queue = new Queue($driver);

if (!$item = $queue->next('payment')) {
    exit;
}

echo 'channel: ' . $item->getChannel() . PHP_EOL;
echo 'id: ' . $item->getId() . PHP_EOL;
echo 'data: ' . print_r($item->getData(), true) . PHP_EOL;

// also can be getting by magic getter: $item->id, $item->channel, $item->data
```

Queue
=====

[](#queue)

Base class for queue manipulate.

Methods
-------

[](#methods)

### `__construct`

[](#__construct)

```
/**
 * @param DriverInterface $driver
 */
public function __construct(DriverInterface $driver);
```

**Flat File (FileSystem) driver:**

```
use Chipslays\Queue\Queue;
use Chipslays\Queue\Drivers\File;

require __DIR__ . '/vendor/autoload.php';

$driver = new File([
    'storage' => __DIR__ . '/storage/',
]);

$queue = new Queue($driver);
```

### `add`

[](#add)

```
/**
 * Add item to queue.
 *
 * Returns the `id` of the added item.
 *
 * @param string $channel
 * @param array $data
 * @param int $sort
 * @return string
 */
public function add(string $channel, array $data, int $sort = QUEUE_DEFAULT_SORT): string;
```

Example:

```
use Chipslays\Queue\Queue;

$queue = new Queue($driver);
$id = $queue->add('payment', ['key' => 'value']);
echo $queue->position('payment', $id); // e.g. 1
```

### `get`

[](#get)

```
/**
 * Get item by ID.
 *
 * @param string $channel
 * @param string $id
 * @return Item|null
 */
public function get(string $channel, string $id): ?Item;
```

Example:

```
use Chipslays\Queue\Queue;

$queue = new Queue($driver);
$id = $queue->add('payment', ['key' => 'value']);
$item = $queue->get('payment', $id));

echo 'channel: ' . $item->getChannel() . PHP_EOL;
echo 'id: ' . $item->getId() . PHP_EOL;
echo 'data: ' . print_r($item->getData(), true) . PHP_EOL;

// also can be getting by magic getter: $item->id, $item->channel, $item->data
```

### `first`

[](#first)

```
 /**
 * Get first item in queue.
 *
 * If queue is empty or `channel` not exists returns `null`.
 *
 * @param string $channel
 * @return Item|null
 */
public function first(string $channel): ?Item;
```

Example:

```
use Chipslays\Queue\Queue;

$queue = new Queue($driver);
$item = $queue->first('payment');

if (!$item) {
    return;
}

echo 'channel: ' . $item->getChannel() . PHP_EOL;
echo 'id: ' . $item->getId() . PHP_EOL;
echo 'data: ' . print_r($item->getData(), true) . PHP_EOL;

// also can be getting by magic getter: $item->id, $item->channel, $item->data
```

### `next`

[](#next)

```
/**
 * Get next item in queue.
 *
 * @param string $channel
 * @return Item|null
 */
public function next(string $channel): ?Item;
```

Example:

```
use Chipslays\Queue\Queue;

$queue = new Queue($driver);

// somewhere in client code...
$queue->add('payment', ['currency' => 'EUR', 'amount' => 10]);

// somewhere in worker/cron code...
if (!$item = $queue->next('payment')) {
    return;
}

echo 'channel: ' . $item->getChannel() . PHP_EOL;
echo 'id: ' . $item->getId() . PHP_EOL;
echo 'data: ' . print_r($item->getData(), true) . PHP_EOL;

// also can be getting by magic getter: $item->id, $item->channel, $item->data
```

### `delete`

[](#delete)

```
/**
 * Delete item from queue.
 *
 * Returns `true` on success delete and `false` on fail.
 *
 * @param string|Item $channel e.g. Can be passed as result from `first` method.
 * @param string $id
 * @return boolean
 */
public function delete($channel, string $id = null): bool;
```

Example:

```
use Chipslays\Queue\Queue;

$queue = new Queue($driver);
$item = $queue->first('payment');

if (!$item) {
    return;
}

// Delete by pass received item from `first` method.
$queue->delete($item);

// Delete by `channel` and `id`.
$queue->delete($item->channel, $item->id);
```

### `list`

[](#list)

```
/**
 * Get list of queue items.
 *
 * Returns array of `id's`, if `channel` not exists returns `null`.
 *
 * @param string $channel
 * @return array|null
 */
public function list(string $channel): ?array;
```

Example:

```
use Chipslays\Queue\Queue;

$queue = new Queue($driver);
print_r($queue->list('payment'));

// Array
//
//     [0] => item_id_1
//     [1] => item_id_2
//     [2] => item_id_3
// )
```

> **NOTE:** For each driver, the name of the `id` may be different!

### `count`

[](#count)

```
/**
 * Get count of items in queue.
 *
 * Returns count, if `channel` not exists returns 0.
 *
 * @param string $channel
 * @return integer
 */
public function count(string $channel): int;
```

Example:

```
use Chipslays\Queue\Queue;

$queue = new Queue($driver);
echo $queue->count('payment'); // e.g. 32
```

### `position`

[](#position)

```
/**
 * Get item position in queue.
 *
 * Return position, if `channel` or `id` not exists returns 0.
 *
 * @param string $channel
 * @param string $id
 * @return int
 */
public function position(string $channel, string $id): int;
```

Example:

```
use Chipslays\Queue\Queue;

$queue = new Queue($driver);
$id = $queue->add('payment', ['key' => 'value']);
echo $queue->position('payment', $id); // e.g. 1
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

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

Recently: every ~51 days

Total

7

Last Release

1642d ago

### Community

Maintainers

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

---

Top Contributors

[![chipslays](https://avatars.githubusercontent.com/u/19103498?v=4)](https://github.com/chipslays "chipslays (30 commits)")

---

Tags

queuequeue-managerqueue-workersqueuemessage queuequeue managerqueue-workers

### Embed Badge

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

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

###  Alternatives

[queue-interop/queue-interop

Promoting the interoperability of MQs objects. Based on Java JMS

48030.5M87](/packages/queue-interop-queue-interop)[bschmitt/laravel-amqp

AMQP wrapper for Laravel and Lumen to publish and consume messages

2752.3M7](/packages/bschmitt-laravel-amqp)[clue/mq-react

Mini Queue, the lightweight in-memory message queue to concurrently do many (but not too many) things at once, built on top of ReactPHP

144691.7k4](/packages/clue-mq-react)[pekkis/queue

Queue abstraction library

18129.9k2](/packages/pekkis-queue)

PHPackages © 2026

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