1. Go to this page and download the library: Download gpslab/middleware 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/ */
gpslab / middleware example snippets
// middleware chain
$chain = new DirectBindingMiddlewareChain();
// add logger middleware
$chain->append(new LoggerMiddleware($logger));
// add validator middleware
$chain->append(new ValidatorMiddleware($validator));
// add middleware for handle command from origin command bus
$chain->append(new CommandMiddleware($command_bus));
// configure command bus
$bus = new MiddlewareCommandBus($chain);
// handle command
try {
$bus->handle($my_command);
} catch(InvalidMessageException $e) {
// show validation errors
var_dump($e->getMessages());
}
// middleware chain
$chain = new DirectBindingMiddlewareChain();
// add logger middleware
$chain->append(new LoggerMiddleware($logger));
// add validator middleware
$chain->append(new ValidatorMiddleware($validator));
// add middleware for handle query from origin query bus
$chain->append(new QueryMiddleware($query_bus));
// configure query bus
$bus = new MiddlewareQueryBus($chain);
// handle query
try {
$bus->handle($my_query);
} catch (InvalidMessageException $e) {
// show validation errors
var_dump($e->getMessages());
}
// middleware chain
$chain = new DirectBindingMiddlewareChain();
// add logger middleware
$chain->append(new LoggerMiddleware($logger));
// add middleware for handle event from origin domain event bus
$chain->append(new DomainEventMiddleware($domain_event_bus));
// configure domain event bus
$bus = new MiddlewareDomainEventBus($chain);
// publish domain event
$bus->publish($my_event);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.