1.0 2014-04-21 15:24 UTC


Queue system in php


Install via Composer

    "require": {
        "juanber84/phpqueue": "dev-master"


Composer generates a vendor/autoload.php file. You can simply include this file and you will get autoloading for free.

require 'vendor/autoload.php';

Example of Publisher

require 'vendor/autoload.php';

use phpqueue\Publisher;

$data = array(
    'name'      => 'juan',
    'surname'   => 'berzal',
    'email'     => 'juanber84@gmail.com'

$messages =json_encode($data);

$publisher = new Publisher();
$publisher->setBlock_send(true);   // synchronous send
//$publisher->setBlock_send(false);  // asynchronous send
$response = $publisher->publish(); // empty response or array of fails

Example of Consumer

require 'vendor/autoload.php';

use phpqueue\Consumer;

$consumer = new Consumer();
do {
    echo $consumer->pickup(); 
    // try it out
} while (true);     

Example of Use

  • Copy the example of publisher code in publisher.php
  • Copy the example of consumer code in consumer.php

Start the consumer

$ php consumer.php

Throw the publiser

$ php publisher.php