This library is a pure asynchronous PHP implementation of the AMQP 0-9-1 protocol.
Code is mostly based on bunnyphp and PHPinnacle Ridge, but use amphp for async operations.
Via Composer
$ composer require pnixx/amp-rabbitmq
<?php
use Amp\Loop;
use PHPinnacle\Ridge\Channel;
use PHPinnacle\Ridge\Client;
use PHPinnacle\Ridge\Message;
use Revolt\EventLoop;
require __DIR__ . '/vendor/autoload.php';
$client = Client::create('amqp://user:pass@localhost:5672');
$client->connect();
$channel = $client->channel();
$queue = $channel->queueDeclare('queue_name');
for ($i = 0; $i < 10; $i++) {
$channel->publish("test_$i", '', 'queue_name');
}
$channel->consume(function (Message $message, Channel $channel) {
echo $message->content() . \PHP_EOL;
$channel->ack($message);
}, 'queue_name');
EventLoop::run();
More examples can be found in examples
directory.
$ composer tests
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.