PHP code example of zt / rabbit-mq

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

    

zt / rabbit-mq example snippets


        $rabbitMq = new \RabbitMQ\RabbitMQ();
        //Send a normal message.
        $rabbitMq->producer('test', 'Hello world!');
        //Send a message delayed by 1 second.
        $rabbitMq->producer('test', [1, 2] , 1000);
        //Send a message delayed by 2 second
        $rabbitMq->producer('test', new stdClass(), 2000);`
    

        $rabbitMq = new \RabbitMQ\RabbitMQ();
        $rabbitMq->consumer('test' , function($msg){
            var_dump($msg);
        });