PHP code example of diswebru / laravel-rabbitmq

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

    

diswebru / laravel-rabbitmq example snippets


use Diswebru\LaravelRabbitMQ\Publish;

Publish::setTopic('test')->sent(['message-key' => 'message-value']);

use Diswebru\LaravelRabbitMQ\Consumer;
use Diswebru\LaravelRabbitMQ\AMQPMessage;

Consumer::setTopic('test')->run(function (AMQPMessage $message) {
    $data = $message->getJson();

    if (!isset($data['message-key']) || $data['message-key'] != 'message-value') {
        // There will be no commit
        throw new \Exception('Error message');
    }
});
bash
php artisan vendor:publish --tag=laravel-rabbitmq-config