PHP code example of mohmann / hexagonal
1. Go to this page and download the library: Download mohmann/hexagonal 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/ */
mohmann / hexagonal example snippets
use mohmann\Hexagonal\Command\AbstractCommand;
use mohmann\Hexagonal\Command\Bus\SimpleCommandBus;
use mohmann\Hexagonal\CommandInterface;
use mohmann\Hexagonal\Exception\HexagonalException;
use mohmann\Hexagonal\Handler\Resolver\HandlerResolver;
use mohmann\Hexagonal\HandlerInterface;
ommand)
{
return \sprintf('%s baz', $command->payload);
}
}
$handlerResolver = new HandlerResolver([
FooCommand::class => new FooHandler(),
]);
$commandBus = new SimpleCommandBus($handlerResolver);
try {
$command = new FooCommand('bar');
$result = $commandBus->execute($command);
var_dump($result);
} catch (HexagonalException $e) {
var_dump($e);
}