PHP code example of xervice / event-rabbitmq
1. Go to this page and download the library: Download xervice/event-rabbitmq 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/ */
xervice / event-rabbitmq example snippets
namespace App\Event;
use Xervice\Event\EventFactory as XerviceEventFactory;
use Xervice\EventRabbitMq\Business\EventProvider\RabbitMqEventProvider;
use Xervice\Event\Business\Provider\EventProviderInterface;
class EventFactory extends XerviceEventFactory
{
/**
* @return \Xervice\Event\Business\Provider\EventProviderInterface
*/
public function createEventProvider(): EventProviderInterface
{
return new RabbitMqEventProvider();
}
}
namespace App\RabbitMQ;
use Xervice\RabbitMQ\RabbitMQDependencyProvider as XerviceRabbitMQDependencyProvider;
use Xervice\EventRabbitMq\Business\Listener\QueueListener;
use Xervice\EventRabbitMq\Business\Queue\EventQueue;
use Xervice\EventRabbitMq\Business\Queue\EventExchange;
class RabbitMQDependencyProvider extends XerviceRabbitMQDependencyProvider
{
/**
* @return array
*/
protected function getListener()
{
return [
new QueueListener()
];
}
/**
* @return \Xervice\RabbitMQ\Queue\QueueInterface[]
*/
protected function getQueues()
{
return [
new EventQueue()
];
}
/**
* @return \Xervice\RabbitMQ\Exchange\ExchangeInterface[]
*/
protected function getExchanges()
{
return [
new EventExchange()
];
}
}