1. Go to this page and download the library: Download workerman/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/ */
workerman / rabbitmq example snippets
use Bunny\Channel;
use Bunny\Message;
use Workerman\Worker;
use Workerman\RabbitMQ\Client;
n(function (Client $client) {
return $client->channel();
})->then(function (Channel $channel) {
return $channel->queueDeclare('hello', false, false, false, false)->then(function () use ($channel) {
return $channel;
});
})->then(function (Channel $channel) {
echo ' [*] Waiting for messages. To exit press CTRL+C', "\n";
$channel->consume(
function (Message $message, Channel $channel, Client $client) {
echo " [x] Received ", $message->content, "\n";
},
'hello',
'',
false,
true
);
});
};
Worker::runAll();