desmart/laravel-commandbus
Composer 安装命令:
composer require desmart/laravel-commandbus
包简介
DeSmart CommandBus for Laravel
README 文档
README
A small, pluggable command bus.
Instalation
$ composer require desmart/laravel-commandbus- Add
DeSmart\CommandBus\ServiceProvidertoapp.php
Example usage:
Command Class
class RegisterUserCommand { protected $email; public function __construct($email) { $this->email = $email; } public function getEmail() { return $this->email; } }
CommandValidator Class
class RegisterUserCommandValidator { public function validate(RegisterUserCommand $command) { // it will be called before handler } }
CommandHandler Class
class RegisterUserCommandHandler { public function handle(RegisterUserCommand $command) { // it will be called if validator won't throw any exception } }
Execute the command:
class Controller { /** * @var \DeSmart\CommandBus\Contracts\CommandBus */ protected $commandBus; public function __construct(\DeSmart\CommandBus\Contracts\CommandBus $commandBus) { $this->commandBus = $commandBus; } public function index() { $command = new RegisterUserCommand("foo@bar.net"); $this->commandBus->handle($command); } }
统计信息
- 总下载量: 3.4k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-03