A lightweight task queue on top of rybakit/phive-queue

Fund package maintenance!

v0.3.0 2014-08-05 08:15 UTC

This package is auto-updated.

Last update: 2021-11-05 12:20:50 UTC


Build Status

A job/task queue on top of the Phive Queue.


The recommended way to install Phive Task Queue is through Composer:

$ composer require rybakit/phive-task-queue:~1.0@dev

Usage example

// worker.php

use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Phive\Queue\SysVQueue;
use Phive\TaskQueue\ExecutionContext;
use Phive\TaskQueue\Executor;
use Phive\TaskQueue\ExecutorAdapter\CallableExecutorAdapter;

// create a queue
// see a list of available queues: https://github.com/rybakit/phive-queue#queues
$queue = new SysVQueue(0xDEADBEAF, true);

// create a logger
// can be any PSR-3 compliant logger
$logger = new Logger('worker');
$logger->pushHandler(new StreamHandler(STDOUT, Logger::INFO));

// create a callback
$callback = function ($payload, LoggerInterface $logger) {

$adapter = new CallbackExecutorAdapter(new DirectCallbackResolver($callback));
$context = new ExecutionContext($queue, $logger);
$executor = new Executor($adapter, $context);

// main loop
while (true) {
    if (!$executor->execute()) {
// client.php

use Phive\Queue\SysVQueue;

$queue = new SysVQueue(0xDEADBEAF, true);

// send a payload object to the queue and delay execution for 5 seconds
// see supported item types: https://github.com/rybakit/phive-queue#item-types
$queue->push('Hello world!', '+5 seconds');


Phive Task Queue is released under the MIT License. See the bundled LICENSE file for details.