<commit_before>ProophServiceBus
===============

PHP Enterprise Service Bus Implementation supporting CQRS and DDD

[![Build Status](https://travis-ci.org/prooph/service-bus.png?branch=master)](https://travis-ci.org/prooph/service-bus)

This library is heavily inspired by [malocher/cqrs-esb](https://github.com/malocher/cqrs-esb), [beberlei/litecqrs-php](https://github.com/beberlei/litecqrs-php) and [szjani/mf4php](https://github.com/szjani/mf4php).

Why another CQRS/Messaging library?
-----------------------------------

The goal of ProophServiceBus is to provide a powerful CQRS layer on top of different messaging/worker tools like [PhpResque](https://github.com/chrisboulton/php-resque), [RabbitMQ](https://www.rabbitmq.com/), [Pheanstalk](https://github.com/pda/pheanstalk) or RESTful Messaging API.
It is designed with flexibility in mind. Almost all components can be extended with custom behavior. But flexibility has it's price. The structure of ProophServiceBus
is more complex than of other libraries. If you just want to get familiar with CQRS and/or messaging, maybe another lib is a better choice.

IoC and EDA
-----------

Like mentioned above, each part of ProophServiceBus can be extended or exchanged. The library uses the [ServiceManager](http://framework.zend.com/manual/2.0/en/modules/zend.service-manager.quick-start.html) and [EventManager](http://framework.zend.com/manual/2.0/en/modules/zend.event-manager.event-manager.html) implementations
of the ZendFramework 2. Specific managers and factories construct the various components used to send commands, publish events and receive them. All important actions trigger *.pre and *.post events to provide event-driven capabilities.
But let's explore it step by step.

Installation
------------

You can install ProophServiceBus via composer by adding `"prooph/service-bus": "dev-master"` as requirement to your composer.json.

Quick Start
-----------

The simplest way to get started is to configure a local in memory service bus. In ProophServiceBus this would not be simple enough to use it as example in a quick start,
but ProophServiceBus ships with an Initializer, that do the hard work for us.

```php
use Prooph\ServiceBus\Example\Command\EchoText;
use Prooph\ServiceBus\Initializer\LocalSynchronousInitializer;
use Prooph\ServiceBus\Service\ServiceBusManager;

//The ServiceBusManager is the central class, that manages the service bus environment
$serviceBusManager = new ServiceBusManager();

//We use an Initializer to configure a local in memory service bus
$localEnvironmentInitializer = new LocalSynchronousInitializer();

//Register a callback as CommandHandler for the EchoText command
$localEnvironmentInitializer->setCommandHandler(
    'Prooph\ServiceBus\Example\Command\EchoText',
    function (EchoText $aCommand) {
        echo $aCommand->getText();
    }
);

//Register the Initializer at the event system of the ServiceBusManager
$serviceBusManager->events()->attachAggregate($localEnvironmentInitializer);

//Get the default CommandBus from ServiceBusManager
$commandBus = $serviceBusManager->getCommandBus();

//Create a new Command
$echoText = new EchoText('It works');

//... and send it to a handler via CommandBus
$commandBus->send($echoText);

//Output should be: It works
```

What's next?
------------

Read the [Wiki](https://github.com/prooph/php-service-bus/wiki)

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 check your code using [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) against [PSR2 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) using `./vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor .`.

<commit_msg>Close #28: Update README<commit_after>ProophServiceBus
===============

PHP Enterprise Service Bus Implementation supporting CQRS and DDD

[![Build Status](https://travis-ci.org/prooph/service-bus.png?branch=master)](https://travis-ci.org/prooph/service-bus)


Why another CQRS/Messaging library?
-----------------------------------

The goal of ProophServiceBus is to provide a powerful CQRS layer on top of different messaging/worker tools like [PhpResque](https://github.com/chrisboulton/php-resque), [RabbitMQ](https://www.rabbitmq.com/), [Pheanstalk](https://github.com/pda/pheanstalk) or RESTful Messaging API.
It is designed with flexibility in mind. Almost all components can be extended with custom behavior and an event-driven system provides various possibilities to hook into the process and adjust it to meet your needs.

IoC and EDA
-----------

Like mentioned above, each part of ProophServiceBus can be extended or exchanged. The library uses the [ServiceManager](http://framework.zend.com/manual/2.0/en/modules/zend.service-manager.quick-start.html) and [EventManager](http://framework.zend.com/manual/2.0/en/modules/zend.event-manager.event-manager.html) implementations
of the ZendFramework 2. Specific managers and factories construct the various components used to send commands, publish events and receive them.
But let's explore it step by step.

Installation
------------

You can install ProophServiceBus via composer by adding `"prooph/service-bus": "~0.3.0"` as requirement to your composer.json.

Quick Start
-----------

The simplest way to get started is to configure a command map
and use the routing mechanism of the ServiceBus to pass a command directly (synchronous) to a command handler.

```php
use Prooph\ServiceBus\Example\Command\EchoText;
use Prooph\ServiceBus\Service\ServiceBusConfiguration;
use Prooph\ServiceBus\Service\ServiceBusManager;

//The ServiceBus environment is set up by a special configuration class
$serviceBusConfig = new ServiceBusConfiguration();

//Register a callback as CommandHandler for the EchoText command
$serviceBusConfig->setCommandMap(array(
    'Prooph\ServiceBus\Example\Command\EchoText' => function (EchoText $aCommand) {
        echo $aCommand->getText();
    }
));

//The ServiceBusManager is the central class, that manages the complete service bus environment
$serviceBusManager = new ServiceBusManager($serviceBusConfig);

//We create a new Command
//Assume that the EchoText command extends Prooph\ServiceBus\Command\AbstractCommand
$echoText = EchoText::fromPayload('It works');

//... and send it to a handler via routing system of the ServiceBus
$serviceBusManager->route($echoText);

//Output should be: It works
```

What's next?
------------

Read the [Wiki](https://github.com/prooph/php-service-bus/wiki)

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 check your code using [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) against [PSR2 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) using `./vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor .`.

Acknowledgement
---------------

This library is heavily inspired by [malocher/cqrs-esb](https://github.com/malocher/cqrs-esb), [beberlei/litecqrs-php](https://github.com/beberlei/litecqrs-php) and [szjani/mf4php](https://github.com/szjani/mf4php).

{'fraction_non_alphanumeric': 0.12344846195358877, 'fraction_numerical': 0.0033729087965461415, 'mean_word_length': 4.344628695025234, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 22, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3414576', 'n_tokens_mistral': 2115, 'n_tokens_neox': 2049, 'n_words': 704}