lefuturiste / rabbitmq-consumer
消费 RabbitMQ 消息的最简单方式
v1.3
2018-08-31 20:58 UTC
Requires
- php-amqplib/php-amqplib: ^2.7
Requires (Dev)
- phpunit/phpunit: ^7.3
This package is auto-updated.
Last update: 2024-09-20 08:02:56 UTC
README
消费 RabbitMQ 消息的最简单方式。
安装
使用 composer 依赖管理器
composer require lefuturiste/rabbitmq-consumer
要求
- PHP >= 7.1
使用方法
在您的 PHP 守护进程脚本中
require 'vendor/autoload.php';
$connection = new \PhpAmqpLib\Connection\AMQPStreamConnection("localhost", 5672, 'username', 'password', 'virtualhost');
$client = new \Lefuturiste\RabbitMQConsumer\Client($connection);
$client->addListener('my_event', function(array $message, $rootValue){
var_dump($message);
echo "\n";
});
$client->listen();
测试
phpunit 测试