PHPackages                             klevialent/tarantool-queue-php - 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. klevialent/tarantool-queue-php

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

klevialent/tarantool-queue-php
==============================

tarantool queue php

00PHP

Since Mar 13Pushed 8y agoCompare

[ Source](https://github.com/klevialent/tarantool-queue-php)[ Packagist](https://packagist.org/packages/klevialent/tarantool-queue-php)[ RSS](/packages/klevialent-tarantool-queue-php/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Tarantool queue tools
=========================

[](#php-tarantool-queue-tools)

Compatible with php7.
Used
[tarantool-php/client](https://github.com/tarantool-php/client)
[tarantool-php/queue](https://github.com/tarantool-php/queue)

[Tarantool](http://tarantool.org/) is a NoSQL database running in a Lua application server. It integrates Lua modules, called [LuaRocks](https://luarocks.org/). This package provides PHP bindings for [Tarantool Queue LuaRock](https://github.com/tarantool/queue/).

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

[](#installation)

The recommended way to install the library is through [Composer](http://getcomposer.org):

```
$ composer require klevialent/tarantool-queue-php
```

QueueProcessController compatible only with yii2, and if you want to use it:

```
$ composer require yiisoft/yii2
```

Before start
------------

[](#before-start)

In order to use queue, you first need to make sure that your Tarantool instance is configured, up and running. The minimal required configuration might look like this:

```
-- queues.lua

box.cfg {listen=3301}

queue = require('queue')
queue.start()

queue.create_tube('foobar', 'fifo', { if_not_exists=true })
```

> You can read more about the box configuration in the official [Tarantool documentation](http://tarantool.org/doc/book/configuration/index.html#initialization-file). For more information about the queue configuration check out [queue's README](https://github.com/tarantool/queue/blob/master/README.md).

To start the instance you need to copy (or symlink) `queues.lua` file into the `/etc/tarantool/instances.enabled`directory and run the following command:

```
$ sudo tarantoolctl start queues
```

Working with queue
------------------

[](#working-with-queue)

See example-yii or read more.

```
$queue = Yii::$app->queue->foobar;

```

### ProsessQueue

[](#prosessqueue)

Implement method process() of WorkerInterface and run it as demon.
If you use yii2

```
//add to config
    'controllerMap' => [
        'queue-process' => WebDevTeam\TarantoolQueuePhp\QueueProcessController::className(),
    ],

//console command
php yii queue-process foobar

```

### Data types

[](#data-types)

Under the hood Tarantool uses [MessagePack](http://msgpack.org/) binary format to serialize/deserialize data being stored in a queue. This means that it's safe to use such data types as `null`, `bool`, `int`, `float`, `string`, `binary string` and `array` without any manual pre- or post-processing:

```
$queue->put('foo');
$queue->put(true);
$queue->put(42);
$queue->put(4.2);
$queue->put(['foo' => ['bar' => ['baz' => null]]]);
```

### Tasks

[](#tasks)

```
Task::getId()
Task::getState() // States::READY, States::TAKEN, States::DONE, States::BURY or States::DELAYED
Task::getData()
```

And some sugar methods:

```
Task::isReady()
Task::isTaken()
Task::isDone()
Task::isBuried()
Task::isDelayed()
```

### Producer API

[](#producer-api)

As you've already seen, to insert a task into a queue you need to call `put()` method, which accepts two arguments: the data you want to process and optional array of task options, which this particular queue supports. For example, `fifottl` queue (which we defined earlier in our Lua config file), supports `delay`, `ttl`, `ttr`, `pri` and `temporary` options:

```
$queue->put('foo', ['delay' => 30]);
$queue->put('bar', ['ttl' => 5]);
$queue->put('baz', ['ttr' => 10, 'pri' => 42]);
```

> See the full list of available options [here](https://github.com/tarantool/queue#queue-types).

### Consumer API

[](#consumer-api)

To reserve a task for execution, call `take()` method. It accepts an optional `timeout` parameter. If a timeout value is supplied the call will wait `timeout` seconds until a `READY` task appears in the queue. The method returns either a [Task](#tasks) object or `null`:

```
$task = $queue->take();
// wait 2 seconds
$task = $queue->take(2);
// wait 100 milliseconds
$task = $queue->take(.1);
```

After successful execution, a task can be marked as acknowledged (that will also delete the task from a queue):

```
$data = $task->getData();

// process $data

$task = $queue->ack($task->getId());
```

Or put back into the queue in case it cannot be executed:

```
$task = $queue->release($task->getId());

// for ttl-like queues you can specify a delay
$task = $queue->release($task->getId(), ['delay' => 30]);
```

To look at a task without changing its state, use:

```
$task = $queue->peek($task->getId());
```

To bury (disable) a task:

```
$task = $queue->bury($task->getId());
```

To reset buried task(s) back to `READY` state:

```
$count = $queue->kick(3); // kick 3 buried tasks
```

A task (in any state) can be deleted permanently with `delete()`:

```
$task = $queue->delete($task->getId());
```

To delete all tasks in a queue:

```
$queue->truncate();
```

> For a detailed API documentation, please read the section "[Using the queue module](https://github.com/tarantool/queue#using-the-queue-module)" of the [queue's README](https://github.com/tarantool/queue/blob/master/README.md).

### Statistics

[](#statistics)

The `stats()` method provides access to the statistical information accumulated since a queue was created:

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

The result of this call might look like this:

```
[
    'tasks' => [
        'taken'   => 1,
        'buried'  => 1,
        'ready'   => 1,
        'done'    => 0,
        'delayed' => 0,
        'total'   => 3,
    ],
    'calls' => [
        'bury' => 1,
        'put'  => 3,
        'take' => 1,
        ...
    ],
]
```

In addition, you can specify a key to return only a subset of the array:

```
$calls = $queue->stats('calls');
$total = $queue->stats('tasks.total');
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/34685686?v=4)[Klevialent Man](/maintainers/klevialent)[@klevialent](https://github.com/klevialent)

---

Top Contributors

[![klevialent](https://avatars.githubusercontent.com/u/34685686?v=4)](https://github.com/klevialent "klevialent (34 commits)")

---

Tags

phpqueuetarantoolyii2

### Embed Badge

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

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

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.5M30](/packages/league-geotools)[illuminate/bus

The Illuminate Bus package.

6045.5M508](/packages/illuminate-bus)[uecode/qpush-bundle

Asynchronous processing for Symfony using Push Queues

1672.5M2](/packages/uecode-qpush-bundle)[jayazhao/think-queue-rabbitmq

为 ThinkPHP5.1 队列增加 RabbitMQ 驱动

141.5k](/packages/jayazhao-think-queue-rabbitmq)[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)
