PHP code example of phpgears / cqrs-symfony-messenger
1. Go to this page and download the library: Download phpgears/cqrs-symfony-messenger 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/ */
phpgears / cqrs-symfony-messenger example snippets
use Gears\CQRS\Symfony\Messenger\CommandBus;
use Gears\CQRS\Symfony\Messenger\CommandHandlerLocator;
use Symfony\Component\Messenger\MessageBus;
use Symfony\Component\Messenger\Middleware\HandleMessageMiddleware;
$commandToHandlerMap = [];
$messengerBus = new MessageBus([
new HandleMessageMiddleware(new CommandHandlerLocator($commandToHandlerMap)),
]);
$commandBus = new CommandBus($messengerBus);
/** @var \Gears\CQRS\Command $command */
$commandBus->handle($command);
use Gears\CQRS\Symfony\Messenger\QueryBus;
use Gears\CQRS\Symfony\Messenger\QueryHandlerLocator;
use Symfony\Component\Messenger\MessageBus;
use Symfony\Component\Messenger\Middleware\HandleMessageMiddleware;
$queryToHandlerMap = [];
$messengerBus = new MessageBus([
new HandleMessageMiddleware(new QueryHandlerLocator($queryToHandlerMap)),
]);
$queryBus = new QueryBus($messengerBus);
/** @var \Gears\CQRS\Command $query */
$result = $queryBus->handle($query);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.