1. Go to this page and download the library: Download jurry/amqp-symfony-bundle 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/ */
jurry / amqp-symfony-bundle example snippets
class NumberController {
public function generate(Request $request)
{
return rand($request->get('min'), $request->get('max'));
}
}
use Jurry\RabbitMQ\Handler\RequestSender;
class FooBar {
/** @var \Jurry\RabbitMQ\Handler\RequestSender*/
private $requestSender;
public function __construct(RequestSender $requestSender)
{
$this->requestSender = $requestSender;
}
public function getRandomNumberFromAnotherApp(int $min = 1, int $max = 10): int
{
return $this->requestSender
->setQueueName('external_queue_name') // This is the queue name which another app listens to
->setRoute('number/generate') // The path to the requested route, without providing the full link
->setMethod('post') // Http request method
->setBody(['min' => $min, 'max' => $max]) // Request body
->sendSync();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.