PHP code example of trntv / yii2-tactician

1. Go to this page and download the library: Download trntv/yii2-tactician library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

trntv / yii2-tactician example snippets


'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' => [
            ...
        ]
    ]
    ...
]

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([
        ...
    ])
])

php composer.phar