amqp-async is an implementation of the AMQP 0.9.1 protocol for PHP designed to work with Icicle.
Potentially supporting Amp in the future.
- PHP 7.0+
The recommended way to install amqp-async is with the Composer package manager. (See the Composer installation guide for information on installing and using Composer.)
Run the following command to use the library in your project:
composer require dataprocessors/amqp-async
You can also manually edit composer.json
to add amqp-async as a project requirement.
// composer.json
{
"require": {
"dataprocessors/amqp-async": "1.0.*"
}
}
<?php
require_once "vendor/autoload.php";
class Demo {
public function go() {
$conn = new DataProcessors\AMQP\AMQPConnection();
yield $conn->connect('127.0.0.1', 5672, 'guest', 'guest');
$channel = yield $conn->channel();
yield $channel->basic_consume('test', '', false, false, false, false,
function($msg) {
echo "Got a message\n";
}
);
}
}
$demo = new Demo();
$coroutine = new Icicle\Coroutine\Coroutine($demo->go());
Icicle\Loop\run();
amqp-async is based on php-amqplib