PHP code example of sergiuszm / php-amqplib

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

    

sergiuszm / php-amqplib example snippets




use PhpAmqpLib\Connection\AMQPConnection;
use PhpAmqpLib\Message\AMQPMessage;

$msg = new AMQPMessage($msg_body);
$ch->batch_basic_publish($msg, $exchange);

$msg2 = new AMQPMessage($msg_body);
$ch->batch_basic_publish($msg2, $exchange);

$ch->publish_batch();

$msg->setBody($body2);
$ch->basic_publish($msg, $exchange);


define('AMQP_DEBUG', true);

... more code


define('AMQP_PROTOCOL', '0.8');
javascript
{
  "varo/php-amqplib": "2.2.*"
  }
}
bash
$ cd php-amqplib/demo
$ php amqp_consumer.php
bash
$ cd php-amqplib/demo
$ php amqp_publisher.php some text to publish
bash
$ php amqp_publisher.php quit
bash
$ php amqp_consumer_non_blocking.php

$properties = array('content_type' => 'text/plain', 'delivery_mode' => 2);
$msg = new AMQPMessage($body, $properties);
$ch->basic_publish($msg, $exchange);