Cqrs Example Php,Prooph Service Bus - 轻量级消息总线支持CQRS和微服务

Prooph Service Bus

PHP 7.1+ lightweight message bus supporting CQRS and Micro Services

Important

This library will receive support until December 31, 2019 and will then be deprecated.

Messaging API

prooph/service-bus is a lightweight messaging facade. It allows you to define the API of your model with the help of messages.

Command messages describe actions your model can handle.

Event messages describe things that happened while your model handled a command.

Query messages describe available information that can be fetched from your (read) model.

prooph/service-bus shields your model. Data input and output ports become irrelevant and no longer influence business logic. We're looking at you Hexagonal Architecture.

prooph/service-bus decouples your model from any framework. You can use a web framework like Zend, Symfony, Laravel and co. to handle http requests and pass them via prooph/service-bus to your model but you can also receive the same messages via CLI or from a messaging system like RabbitMQ or Beanstalkd.

It is also a perfect fit for microservices architecture as it provides an abstraction layer for message-based inter-service communication.

Installation

You can install prooph/service-bus via composer by running composer require prooph/service-bus, which will install the latest version as requirement to your composer.json.

Quick Start

use Prooph\ServiceBus\CommandBus;

use Prooph\ServiceBus\Example\Command\EchoText;

use Prooph\ServiceBus\Plugin\Router\CommandRouter;

$commandBus = new CommandBus();

$router = new CommandRouter();

//Register a callback as CommandHandler for the EchoText command

$router->route('Prooph\ServiceBus\Example\Command\EchoText')

->to(function (EchoText $aCommand): void {

echo $aCommand->getText();

});

//Expand command bus with the router plugin

$router->attachToMessageBus($commandBus);

//We create a new Command

$echoText = new EchoText('It works');

//... and dispatch it

$commandBus->dispatch($echoText);

//Output should be: It works

Live Coding Introduction

Documentation

Documentation is in the docs tree, and can be compiled using bookdown.

$ php ./vendor/bin/bookdown docs/bookdown.json

$ php -S 0.0.0.0:8080 -t docs/html/

Support

Ask questions on Stack Overflow tagged with #prooph.

Say hello in the prooph gitter chat.

Contribute

Please feel free to fork and extend existing or add new features and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.

License

Released under the New BSD License.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值