A message queue API for PHP
, (*1)
Rock MQ on Packagist, (*2)
Features
Installation
From the Command Line:, (*3)
composer require romeoz/rock-mq:*@dev, (*4)
In your composer.json:, (*5)
{
"require": {
"romeoz/rock-mq": "*@dev"
}
}
Quick Start
Run broker:, (*6)
php tests/data/mq/rabbit/simple_server.php &
Code:, (*7)
use rock\mq\RabbitQueue;
$rabbit = new RabbitQueue();
$rabbit->send('test'); // result: "Hi! I am server: test"
// or background
$rabbit->sendBackground('test');
Pub/Sub
Run broker:, (*8)
php tests/data/mq/rabbit/pub_server.php &
Code:, (*9)
use rock\mq\RabbitQueue;
$rabbit = new RabbitQueue();
$rabbit->blocking = false;
$rabbit->type = 'direct';
$rabbit->exchange = 'direct_test';
$rabbit->subscribe('foo'); // result: "Hi! I am server: foo"
Requirements
- PHP 5.4+
-
Gearman should be installed
apt-get install libgearman7. Also, should be installed PHP extension apt-get install php5-gearman
-
RabbitMQ should be installed
apt-get install rabbitmq-server.
-
ZeroMQ should be installed
apt-get install libzmq3. Also, should be installed PHP extension apt-get install php-zmq
Note: if you have problems with the installation, then see config .travis., (*10)
License
A message queue API is open-sourced software licensed under the MIT license., (*11)