maximecolin/car
最新稳定版本:1.0.0
Composer 安装命令:
composer require maximecolin/car
包简介
A PHP implementation of the command bus pattern for DDD
README 文档
README
#Car
Car is a PHP implementation of the Command Bus pattern for DDD.
##Disclaimer
This is a very basic and simple implementation. It has to grow up :)
##Installation
composer require maximecolin/car
##Purpose
The aim of the command bus pattern is to isolate your domain code in atomic, testable and reusable classes and to execute them through a dedicated service.
##Usage
A command is an order. It can contains data you need. Attributes can be set on construct, fill through a form, set by other services, ...
class CreateArticleCommand implements CommandInterface { public $title; public $content; public function __construct($title, $content) { $this->title = $title; $this->content = $content; } }
Create an handler which will process your command.
class CreateCommandHandler implements CommandHandlerInterface { public function handle(CommandInterface $command) { // Place here you domain code which create an article ... } }
// Usually, have a service to get the bus $bus = new CommandBus(); $bus->addResolver(new ClassNameResolver()); $command = new CreateArticleCommand('My article name', 'My article content'); $bus->execute($command);
##Comming soon
Event sourcing integration.
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-18