PHP code example of colearn / rabbitmq

1. Go to this page and download the library: Download colearn/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/ */

    

colearn / rabbitmq example snippets

bash
php artisan vendor:publish --provider="CoLearn\RabbitMQ\RabbitMQServiceProvider"

$this->rabbit = app('rabbitmq.queue')->connection('rabbitmq');
RabbitMQ::declareRPCServer($this->rabbit, 'name_of_queue', function ($request) {
    # code...
});

$this->rabbit = app('rabbitmq.queue')->connection('rabbitmq');
$stringInput = json_encode(array);
$response = RabbitMQ::declareRPCClient($this->rabbit, 'name_of_queue', $stringInput);

$this->rabbit = app('rabbitmq.queue')->connection('rabbitmq');
RabbitMQ::declareWorkerQueueServer($this->rabbit, 'name_of_queue', function ($request) {
    RabbitMQ::declareAck($request);
});