PHP code example of dmt-software / command-bus-validator
1. Go to this page and download the library: Download dmt-software/command-bus-validator 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/ */
dmt-software / command-bus-validator example snippets
// src/CommandBus/builder.php
use DMT\CommandBus\Validator\ValidationMiddleware;
use League\Tactician\CommandBus;
use League\Tactician\Handler\CommandHandlerMiddleware;
/** @var CommandHandlerMiddleware $commandHandlerMiddleware */
$commandBus = new CommandBus(
[
new ValidationMiddleware(),
$commandHandlerMiddleware
]
);
// src/CommandBus/builder.php
use DMT\CommandBus\Validator\ValidationMiddleware;
use League\Tactician\CommandBus;
use League\Tactician\Handler\CommandHandlerMiddleware;
use Symfony\Component\Validator\ValidatorBuilder;
$validator = (new ValidatorBuilder())
->addYamlMapping('config/validation.yaml')
->getValidator();
/** @var CommandHandlerMiddleware $commandHandlerMiddleware */
$commandBus = new CommandBus(
[
new ValidationMiddleware($validator),
$commandHandlerMiddleware
]
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.