PHP code example of jarir-ahmed / message-broker

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

    

jarir-ahmed / message-broker example snippets


use JarirAhmed\MessageBroker\MessageBroker;

$broker = new MessageBroker(
    ['custom', 'rabbitmq'],
    [
        'rabbitmq' => [
            'host' => 'localhost',
            'user' => 'guest',
            'password' => 'guest',
        ],
    ]
);

$broker->connect();
$broker->publish('orders.created', json_encode(['id' => 123], JSON_THROW_ON_ERROR));
$broker->close();