1. Go to this page and download the library: Download minms/rabbitmq library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
minms / rabbitmq example snippets
# 创建消息结构
class TestMessage extends \Minms\RabbitMQ\Message
{
public function __construct($index, $pushTime)
{
parent::__construct(compact('index', 'pushTime'), TestHandler::class);
}
}
# 创建消息对应消费方法
class TestHandler extends \Minms\RabbitMQ\Handler
{
public function run()
{
echo date('Y-m-d H:i:s')." 队列消息消费: pushTime: ". $this->getBody("pushTime") . ", index: ".$this->getBody("index")." \n";
}
}