PHP code example of rooooodik / yii2-amqp
1. Go to this page and download the library: Download rooooodik/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/ */
rooooodik / yii2-amqp example snippets
return [
...
'components' => [
...
'amqp' => [
'class' => 'rooooodik\amqp\components\Amqp',
'host' => '127.0.0.1',
'port' => 5672,
'user' => 'your_login',
'password' => 'your_password',
'vhost' => '/',
],
...
],
...
'controllerMap' => [
...
'rabbit' => [
'class' => 'rooooodik\amqp\controllers\AmqpListenerController',
'interpreters' => [
'my-exchange' => 'app\components\RabbitInterpreter', // interpreters for each exchange
],
'exchange' => 'my-exchange', // default exchange
],
...
],
...
];
namespace app\components;
use rooooodik\amqp\components\AmqpInterpreter;
class RabbitInterpreter extends AmqpInterpreter
{
/**
* 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));
}
}
$ php composer.phar
bash
$ php yii rabbit