Tavshan is a simplified Rabbit MQ library written on top of the PHP AMQP Library. It doesn't utilise all the bells and whistles within Rabbit MQ yet, but will be enhanced as required (or with your contributions).
It's actually tavşan (pronounced as tavshan), and means rabbit in Turkish.
Include it by adding mamluk/tavhan
to your composer.json
file.
use Mamluk\Tavhan\Queue
use Monolog\Logger;
use Psr\Log\LogLevel;
$logger = new Monolog\Logger('myQueue');
$logger->pushHandler(new StreamHandler('php://stdout', LogLevel::DEBUG));
$q = new Queue($config, $logger, 'queue_name', 1); // See __construct() src/Queue for what the config array requires
// Produce a message
$q->publish('My first message');
// Consume messages
$callback = function ($msg) {
echo ' [x] Received ', $msg->body, "\n";
};
$this->q->subscribe($callback, 'queue_name');
MIT