PHPackages                             pavelmics/yii-tactician - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. pavelmics/yii-tactician

ActiveLibrary[Framework](/categories/framework)

pavelmics/yii-tactician
=======================

Yii adapter for league/tactician command bus pattern implimentation

0.1.1(10y ago)85.6k↓50%1MITPHP

Since Sep 21Pushed 10y ago2 watchersCompare

[ Source](https://github.com/pavelmics/YiiTactician)[ Packagist](https://packagist.org/packages/pavelmics/yii-tactician)[ Docs](https://github.com/pavelmics/YiiTactician)[ RSS](/packages/pavelmics-yii-tactician/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

\#Yii-Tactician Yii-Tactician is yii addapter for [Tactician command bus library](https://tactician.thephpleague.com/). It provides an easy way to use the command bus pattern in Yii-based apps.

\##Installation You can install Yii-Tactician via composer by running `composer require pavelmics/yii-tactician`or just add `"pavelmics/yii-tactician": "0.1.1"`to your composer.json file.

\##Configuration Once the library is installed, modify your application configuration as follows:

```
return [
	...
	'components' => [
    	...
		'commandBus' => [
    		'class' => 'YiiTactician\YiiTacticianCommandBus',
        ],
    ],
    ...
];

```

By default Yii Tactician uses bus\_commands directory for storing command handlers, you can change this by configuring `handlersPath` with array of yii-aliases as follow:

```
return [
	...
	'components' => [
    	...
		'commandBus' => [
    		'class' => 'YiiTactician\YiiTacticianCommandBus',
            'handlersPath' => [
            	'application.command_bus.handlers',
                'appliction.modules.command_bus',
            ],
        ],
    ],
    ...
];

```

NOTE: don't use \* aliases, your aliases must point to a dirrectory but not a file! NOTE2: Also you have to use psr-4 autoload system to use Yii-Tactician (just add `require('path/to/vendor/autoload.php');` to your index.php and console.php).

\##Usage

\###Basic Define a command class somewhere in your application, for example:

```
class TestCommand
{
	public $someParam;
    public $someOtherParam;

    public function __construct($someParam, $someOtherParam = 'defaultValue')
    {
    	$this->someParam = $someParam;
        $this->someOtherParam = $someOtherParam;
    }
}

```

Then, define a handler class under one of your handlers path (see configuration section of this readme). The name of handler class must be the same as the name of command class suffixed with "Handler". For example for class `TestCommand` we need to define `TestCommandHandler` class:

```
class TestCommandHandler
{
	public function handle(TestCommand $command)
    {
    	// do command stuff hire!
        // we can use $command->someParam and $this->someOtherParam
    }
}

```

Now we can use this command in controllers (or wherever you want):

```
...
public function actionCreateSomething()
{
	$someParam = Yii::app()->request->getPost('some_param');
	$command = new TestCommand($someParam);
    $result = Yii::app()->commandBus->handle($command);
    if ($result) {
    	$this->redirect(
        	Yii::app()->createUrl('something/show', ['id' => $result->id])
        );
    } else {
    	$this->render('errorSomething');
    }
}

```

\###Controller based handlers Sometimes we need handle one command in several different ways. Let's say we need to register users. Sometimes users register by email and sometimes by phone number. We need to handle register command almost the same but at the same time a bit different. To achive this we can define several handler-functions in handler class (like in standart Yii controller). For example:

```
class RegisterCommandHandler
{
	public function byPhone($command)
    {/* code to register by phone */}

    public function byEmail($command)
    {/* code to register by email */}
}

```

And then use `YiiTactician\ControllerBaseCommand` to define your command class:

```
class RegisterCommand extends YiiTactician\ControllerBaseCommand
{}

```

Now you can do something like this:

```
$params = ['email' => 'test@test.com', 'password' => 'pass'];
$command = new RegisterCommand($params, 'byEmail');
\Yii::app()->commandBus->handle($command);

// or
$params = ['phone' => '99-99-99-99'];
$command = new RegisterCommand($params);
$command->setHandlerMethod('byPhone');
\Yii::app()->commandBus->handle($command);

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3893d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/950fe45c4fc9071d9d41a5d4834d869345d8ce0ebee03eaa8e19f4b742b63fe6?d=identicon)[pavelmics](/maintainers/pavelmics)

---

Top Contributors

[![pavelmics](https://avatars.githubusercontent.com/u/3299192?v=4)](https://github.com/pavelmics "pavelmics (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pavelmics-yii-tactician/health.svg)

```
[![Health](https://phpackages.com/badges/pavelmics-yii-tactician/health.svg)](https://phpackages.com/packages/pavelmics-yii-tactician)
```

###  Alternatives

[league/tactician-bundle

Bundle to integrate Tactician with Symfony projects

24810.1M18](/packages/league-tactician-bundle)[koriym/dii

Dependency Injection Plugin for Yii 1

17195.8k](/packages/koriym-dii)[mikemix/tactician-module

Laminas/Mezzio Module to use the League of Extraordinary Packages' Tactician library - flexible command bus implementation

17156.2k](/packages/mikemix-tactician-module)[cherif/yii2-tactician

Yii2 component for Tactician command bus library

201.8k1](/packages/cherif-yii2-tactician)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
