All Projects → trntv → yii2-tactician

trntv / yii2-tactician

Licence: BSD-3-Clause license
Tactician adapter for Yii2

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to yii2-tactician

idea
Gestor de actividades en grupo
Stars: ✭ 16 (+14.29%)
Mutual labels:  command-bus
yii2-command-bus
Command Bus for Yii2
Stars: ✭ 56 (+300%)
Mutual labels:  command-bus
cqrs
A foundational package for Command Query Responsibility Segregation (CQRS) compatible with Laravel.
Stars: ✭ 37 (+164.29%)
Mutual labels:  command-bus

Yii2 Tactician

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 protected]',
    'to' => '[email protected]',
    'body' => '...'
]))

Yii::$app->commandBus->handleMultiply([
    new SendEmailCommand([
        'from' => '[email protected]',
        'to' => '[email protected]',
        'body' => '...'
    ]),
    new SomeOtherCommand([
        ...
    ])
])
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].