PHP code example of sunspikes / carrot

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

    

sunspikes / carrot example snippets


$carrot = new Carrot('test-exchange', 'direct', $config);
$consumer = $carrot->getConsumer();

$consumer->add('TestQueue', function($message) {
    print $message->text;
});

$consumer->listen('test-exchange');

$ php example/consumer.php

[*] Consumer starting to listen for messages from rabbitmq...
[*] Received message: hello

$ php example/producer.php

[*] Producer started...
[*] Producer sent message to rabbitmq