PHP code example of pnixx / amp-rabbitmq

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

    

pnixx / amp-rabbitmq example snippets




use Amp\Loop;
use PHPinnacle\Ridge\Channel;
use PHPinnacle\Ridge\Client;
use PHPinnacle\Ridge\Message;
use Revolt\EventLoop;

l->queueDeclare('queue_name');

for ($i = 0; $i < 10; $i++) {
    $channel->publish("test_$i", '', 'queue_name');
}

$channel->consume(function (Message $message, Channel $channel) {
    echo $message->content() . \PHP_EOL;

    $channel->ack($message);
}, 'queue_name');

EventLoop::run();