Queue abstraction library

Installs: 7 609

Dependents: 1

Stars: 9

Watchers: 2

Forks: 5

Open Issues: 1

Language: PHP

v1.0.1 2015-07-22 11:19 UTC


Build Status

A small, opinionated queue abstraction library based on discovered needs. Extracted from Xi Filelib and other assorted projects.

What does it do?

A message consists of a topic and arbitrary data (basic serializable data supported by default, custom serializers can be added). Messages are moved and grooved through a queue. The library extracts a simple, 80/20 like domain for it's method of operation and abstracts away the differences in message queue backends.



namespace Pekkis\Queue\Example;

use Pekkis\Queue\Adapter\IronMQAdapter;
use Pekkis\Queue\Message;
use Pekkis\Queue\Queue;

require_once (is_file(__DIR__ . '/bootstrap.php')) ? __DIR__ . '/bootstrap.php' : __DIR__ . '/bootstrap.dist.php';

// Create a new IronMQ backed queue
$queue = new Queue(
    new IronMQAdapter(IRONMQ_TOKEN, IRONMQ_PROJECT_ID, 'pekkis-queue-example')

// Queues can be emptied.

// A message consists of a topic and data. A message instance with an UUID you can use is returned.
$message = $queue->enqueue(
        'some' => 'random data'

// Dequeue and process a single message
$received = $queue->dequeue();
$data = $received->getData();

// Acknowledge the message (you're done with it)

A better example

For an end-to-end example with IronMQ and a "real life" scenario, see the folder examples.

Also see Xi Filelib (v0.10+) for actual real use case from the real world!

Ideas / wishes? Contact or create a pull request! Cheers!

Supported queues

  • RabbitMQ (via PECL and pure PHP).
  • IronMQ
  • Amazon SQS

Version upgrades

Refer to the change log