xtremsoft / tactician-provider
此包的最新版本(dev-master)没有提供许可证信息。
Laravel ServiceProvider 用于 Tactician 命令总线库
dev-master
2015-04-05 01:50 UTC
Requires
- php: >=5.5
- illuminate/support: 5.0.*
- league/tactician: 0.5.*
This package is not auto-updated.
Last update: 2024-09-28 17:12:38 UTC
README
Laravel ServiceProvider 用于 Tactician 库 https://github.com/thephpleague/tactician/
如果您正在寻找一个 Symfony2 Bundle 或想提供帮助: https://github.com/xtrasmal/TacticianBundle
设置
首先将此提供者添加到您的 composer 依赖项中
> composer require xtrasmal\tactician-provider
然后在 config/app.php 中注册它。
'providers' => [ 'Xtrasmal\TacticianProvider\TacticianServiceProvider', // ...
就是这样!
配置命令处理器
使用 Tactician 最常见的用例是将命令传递给命令总线,并将其路由到命令总线。
由于处理器通常具有额外的依赖项并且最好是延迟加载,因此您需要将它们注册到 IoC 容器中。
假设我们有两个类,RegisterUserCommand
和 RegisterUserHandler
。将以下内容添加到 config/tactician.php
return [ 'buses' => [ 'default' => [ 'commandbus' => 'League\Tactician\CommandBus', 'middleware' => [ // ... ], 'commmands' => [ 'RegisterUser' => [ 'command' => 'Namespace\RegisterUserCommand', 'handler' => 'Namespace\RegisterUserHandler' ], 'RemoveUser' => [ 'command' => 'Namespace\RemoveUserCommand', 'handler' => 'Namespace\RemoveUserHandler' ], // ... ], ], ], ];