PHP code example of gember / message-bus-symfony
1. Go to this page and download the library: Download gember/message-bus-symfony 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/ */
gember / message-bus-symfony example snippets
use Gember\MessageBusSymfony\SymfonyCommandBus;
use Gember\MessageBusSymfony\SymfonyEventBus;
use Symfony\Component\Messenger\Handler\HandlersLocator;
use Symfony\Component\Messenger\MessageBus;
use Symfony\Component\Messenger\Middleware\HandleMessageMiddleware;
$eventBus = new SymfonyEventBus(
new MessageBus([ // An event bus configuration of your choice
new HandleMessageMiddleware(new HandlersLocator([
SomeEvent::class => [new SomeEventSubscriber()], // callables
// ...
]), allowNoHandlers: true), // events without handlers are normal
]),
);
$commandBus = new SymfonyCommandBus(
new MessageBus([ // A command bus configuration of your choice
new HandleMessageMiddleware(new HandlersLocator([
SomeCommand::class => [new SomeCommandHandler()],
// ...
])),
]),
);