PHP code example of lezhnev74 / prooph-direct-router
1. Go to this page and download the library: Download lezhnev74/prooph-direct-router 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/ */
lezhnev74 / prooph-direct-router example snippets
namespace Some\Space;
// your command
class Command {}
// your command handler
class CommandHandler {
function __invoke(Command $cmd) {...}
}
//...
'service_bus' => [
'command_bus' => [
'router' => [
'routes' => [
// list of commands with corresponding command handler
],
'type' => \DirectRouter\DirectRouter::class
],
],
//…
//
// Manual message bus setup
// 1. Prepare router
$router = new DirectRouter();
$router->attachToMessageBus($commandBus);
// 2. Add service locator (to instantiate the handler). $container is your implementation of PSR-11 ContainerInterface
$locator = new ServiceLocatorPlugin($container);
$locator->attachToMessageBus($bus);
//
// Dispatch command
//
$command = new \Some\Space\Command(...);
$commandBus->dispatch($command);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.