1. Go to this page and download the library: Download devyk/yii2-amqp 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/ */
namespace app\components;
use devyk\amqp\components\AmqpInterpreter;
use app\services\ExampleServiceInterface;
class RabbitInterpreter extends AmqpInterpreter
{
protected $service;
/**
* Example of passing custom service as dependency for the AmqpInterpreter
*/
public function __construct(ExampleServiceInterface $exampleService)
{
$this->service = $exampleService;
parent::__construct();
}
/**
* Interprets AMQP message with routing key 'hello_world'.
*
* @param array $message
*/
public function readHelloWorld($message)
{
// todo: write message handler
$this->log(print_r($message, true));
}
}