1. Go to this page and download the library: Download vu/zf2-amqp-carapace 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/ */
//Easiest way using predefined application settings
$publisher_factory = new Vu\Zf2AMQPCarapace\Publisher\PublisherFactory();
$myapp_amqp_publisher = $publisher_factory->getPublisher('MyApp');
//You may also create an AMQPPublisher manually using Connection, Transport, and Message objects
$connection_factory = new Vu\Zf2AMQPCarapace\Factory\Connection();
$amqp_connection = $connection_factory->create('connection_rabbit'); //Uses predefined connection config
//Create transport and message objects using Transport and Message factories in the same manner...
//More information on Connection, Transport, and Message factories are listed further down on this page
$manual_amqp_publisher = $publisher_factory->makePublisher($amqp_connection, $amqp_transport, $amqp_message);
//Lastly, you may create an AMQPPublisher by passing in an array of configuration
$config = [
'connection' => [/* connection settings */],
'transport' => [/* transport settings */],
'message' => [/* message settings */]
];
$manual_amqp_publisher = $publisher_factory->makePublisherFromConfiguration($config);
//Publish a single message
$my_first_message = "This will be the first message I publish!";
$myapp_amqp_publisher->basicPublish($my_first_message);
$myapp_amqp_publisher->basicPublish("I also want to publish this message");
//Publish multiple messages
$array_of_strings = [
"First!",
"Second...",
"Tres!!"
];
$myapp_amqp_publisher->batchBasicPublish($array_of_strings);
$publisher_factory->getPublisher('AnotherApp')->basicPublish("Here is my message!");