trntv / yii2-tactician
A simple, flexible command bus. This package provide it's integration with Yii2
Installs: 44 314
Dependents: 0
Suggesters: 0
Security: 0
Stars: 14
Watchers: 4
Forks: 6
Open Issues: 0
Type:yii2-extension
Requires
- league/tactician: ^0.6.0
- yiisoft/yii2: ~2.0.13
This package is auto-updated.
Last update: 2024-11-22 09:30:15 UTC
README
Tactician is a simple, flexible package allows you to easy implement Command Bus pattern in your application. This package provide it's very basic integration with Yii2
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require trntv/yii2-tactician
or add
"trntv/yii2-tactician": "*"
to the require section of your composer.json
file.
Usage
Somewhere in your config:
'components' => [ ... 'commandBus' => [ 'class' => '\trntv\tactician\Tactician', 'commandNameExtractor' => '\League\Tactician\Handler\CommandNameExtractor\ClassNameExtractor' 'methodNameInflector' => '\League\Tactician\Handler\MethodNameInflector\HandleInflector' 'commandToHandlerMap' => [ 'app\commands\command\SendEmailCommand' => 'app\commands\handler\SendEmailHandler' ], 'middlewares' => [ ... ] ] ... ]
Somewhere in your app:
Yii::$app->commandBus->handle(new SendEmailCommand([ 'from' => 'email@example.org', 'to' => 'user@example.org', 'body' => '...' ])) Yii::$app->commandBus->handleMultiply([ new SendEmailCommand([ 'from' => 'email@example.org', 'to' => 'user@example.org', 'body' => '...' ]), new SomeOtherCommand([ ... ]) ])