
Echo statements were inconsistent in the use of double quotes vs. single quotes. Some echo statements had spaces between arguments, some did not.
25 lines
597 B
PHP
25 lines
597 B
PHP
<?php
|
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
use PhpAmqpLib\Connection\AMQPStreamConnection;
|
|
|
|
$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
|
|
$channel = $connection->channel();
|
|
|
|
$channel->queue_declare('hello', false, false, false, false);
|
|
|
|
echo " [*] Waiting for messages. To exit press CTRL+C\n";
|
|
|
|
$callback = function ($msg) {
|
|
echo ' [x] Received ', $msg->body, "\n";
|
|
};
|
|
|
|
$channel->basic_consume('hello', '', false, true, false, false, $callback);
|
|
|
|
while (count($channel->callbacks)) {
|
|
$channel->wait();
|
|
}
|
|
|
|
$channel->close();
|
|
$connection->close();
|