1. Go to this page and download the library: Download dreanarc/rabbitmq-adapter 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/ */
dreanarc / rabbitmq-adapter example snippets
use Dreanarc\RabbitMQAdapter\RabbitMQProducer;
$producer = new RabbitMQProducer(
'localhost',
'5672',
'guest',
'guest'
);
$data = "";
$producer->sendMessage('queue_name', $data);
use Dreanarc\RabbitMQAdapter\RabbitMQConsumer;
use PhpAmqpLib\Message\AMQPMessage;
$consumer = new RabbitMQConsumer(
'localhost',
'5672',
'guest',
'guest'
);
$consumer->consume('queue_name', function(AMQPMessage $message){
echo 'Received message: ', $message->getBody(), PHP_EOL;
});
defined('BASEPATH') or exit('No direct script access allowed');
$config['rabbitmq_host'] = 'localhost';
$config['rabbitmq_port'] = 5672;
$config['rabbitmq_user'] = 'guest';
$config['rabbitmq_password'] = 'guest';