cherif/yii2-tactician

Yii2 component for Tactician command bus library

Installs: 1 752

Dependents: 1

Suggesters: 0

Security: 0

Stars: 20

Watchers: 4

Forks: 2

Open Issues: 0

Type:yii2-extension

0.3 2015-09-14 14:22 UTC

This package is not auto-updated.

Last update: 2024-11-09 19:16:30 UTC


README

Tactician command bus library wrapper for Yii2

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist cherif/yii2-tactician "*"

or add

"cherif/yii2-tactician": "*"

to the require section of your composer.json file.

Usage

In the configuration file the component must be in the application bootstrap configuration:

...
'components'=>[
...
				'commandBus'=> [
					'class'=>'cherif\tactician\Tactician',
					'inflector' => 'League\Tactician\Handler\MethodNameInflector\HandleClassNameInflector',
					'extractor' => 'League\Tactician\Handler\CommandNameExtractor\ClassNameExtractor',
					'commandHandlerMap'=> [
						'cherif\tactician\tests\fixtures\commands\CompleteTaskCommand' => 'cherif\tactician\tests\fixtures\handlers\CompleteTaskCommandHandler',
					]
				]
			]

Somewhere in your app (maybe controller):

	Yii:$app->commandBus->handle(new CompleteTaskCommand)

You can add additional middlewares before handling a command like this:

$middleware = new MiddlewareClass();
$command = new MyCommand();

Yii::$app->commandBus->registerMiddleware($middleware);

Yii::$app->commandBus->handle($command);

For more information about configuration please visit Tactician library homepage.