mmalessa/command-bus-bundle

实现command-bus的简单库。

安装: 11

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

公开问题: 0

类型:symfony-bundle

v1.2 2019-09-01 11:18 UTC

This package is auto-updated.

Last update: 2024-09-29 05:48:40 UTC


README

需要Symfony 4.3.*
https://github.com/mmalessa/command-bus-bundle
使用风险自负。

安装

composer req mmalessa/command-bus-bundle

使用示例

注册处理程序

services:
    App\Application\CommandBus\TestCommandHandler:
        tags:
            - { name: mmalessa.command_handler }

基于处理程序 'handle' 方法中参数的类型,自动检测命令类。

创建命令和处理程序

(见 - README 中的 mmalessa/command-bus 包。)

将命令总线注入到Symfony命令/控制器中

use Mmalessa/CommandBus/CommandBus
public function __construct(CommandBus $commandBus)
// [...]

处理命令

$command = TestCommand::create(1, 'Silifon');
$this->commandBus->handle($command);