PHP code example of phpinnacle / ridge
1. Go to this page and download the library: Download phpinnacle/ridge 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/ */
phpinnacle / ridge example snippets
use Amp\Loop;
use PHPinnacle\Ridge\Channel;
use PHPinnacle\Ridge\Client;
use PHPinnacle\Ridge\Message;
connect();
/** @var Channel $channel */
$channel = yield $client->channel();
yield $channel->queueDeclare('queue_name');
for ($i = 0; $i < 10; $i++) {
yield $channel->publish("test_$i", '', 'queue_name');
}
yield $channel->consume(function (Message $message, Channel $channel) {
echo $message->content() . \PHP_EOL;
yield $channel->ack($message);
}, 'queue_name');
});