PHP code example of dimkabelkov / rabbit-bus-bundle

1. Go to this page and download the library: Download dimkabelkov/rabbit-bus-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/ */

    

dimkabelkov / rabbit-bus-bundle example snippets


rabbit_bus
    event_classes:
        - YouProject\Event\ExamampleEvent
    events
        multiple: true
        consumers:
            - !php/const YouProject\Event\ExamampleEvent::EXCHANGE



namespace App\EventListener;

use YouProject\Event\ExamampleEvent;
use Psr\Log\LoggerAwareInterface;
use Exception;
use Psr\Log\LoggerAwareTrait;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class EventBusSubscriber implements EventSubscriberInterface, LoggerAwareInterface
{
    use LoggerAwareTrait;

    /**
     * @return array
     */
    public static function getSubscribedEvents(): array
    {
        return [
            ExamampleEvent::class => 'onExamampleEvent',
        ];
    }

    /**
     * @param ExamampleEvent $event
     *
     * @throws Exception
     */
    public function onExamampleEvent(ExamampleEvent $event)
    {
        $this->logger->info('Check handle event', $event->toArray());
    }
}