PHP code example of pccomponentes / common-bus
1. Go to this page and download the library: Download pccomponentes/common-bus 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/ */
pccomponentes / common-bus example snippets
$bus = new CommandBusSync();
$bus->register(YourCommandClass::class, new Your\Invokable\Handler());
$bus->dispatch(new YourCommandClass());
final class MyController
{
private $bus;
public function __construct(CommandBusSync $bus)
{
$this->bus = $bus;
}
public function __invoke(Request $request)
{
$this->bus->dispatch(
new Your\Command\Class(
new Uuid($request->get('request_id'))
)
);
}
}