PHPackages                             spekkionu/tactician-container-selfhandling - 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. [API Development](/categories/api)
4. /
5. spekkionu/tactician-container-selfhandling

ActiveLibrary[API Development](/categories/api)

spekkionu/tactician-container-selfhandling
==========================================

Container-Aware Self-Handling commands for Tactician Command Bus

1.0.1(9y ago)12231MITPHP

Since Oct 26Pushed 8y ago1 watchersCompare

[ Source](https://github.com/spekkionu/tactician-container-selfhandling)[ Packagist](https://packagist.org/packages/spekkionu/tactician-container-selfhandling)[ RSS](/packages/spekkionu-tactician-container-selfhandling/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (4)Versions (3)Used By (1)

Tactician Container-Aware Self-Handling Commands
================================================

[](#tactician-container-aware-self-handling-commands)

[![Latest Stable Version](https://camo.githubusercontent.com/832a32f136efabb2d703dfa7ca08875f351a9baa055824f6da8d15c6e9e4b6d3/68747470733a2f2f706f7365722e707567782e6f72672f7370656b6b696f6e752f74616374696369616e2d636f6e7461696e65722d73656c6668616e646c696e672f762f737461626c65)](https://packagist.org/packages/spekkionu/tactician-container-selfhandling)[![Build Status](https://camo.githubusercontent.com/27c53413934eb289a5c2f990b5350f1bcb08067abb09f57a9ada92dc1c9d9f7e/68747470733a2f2f7472617669732d63692e6f72672f7370656b6b696f6e752f74616374696369616e2d636f6e7461696e65722d73656c6668616e646c696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/spekkionu/tactician-container-selfhandling)[![License](https://camo.githubusercontent.com/74ab49e36e1cafe2d5af62024e7d6ff6683c6f7e77707e7d714731807c90f557/68747470733a2f2f706f7365722e707567782e6f72672f7370656b6b696f6e752f74616374696369616e2d636f6e7461696e65722d73656c6668616e646c696e672f6c6963656e7365)](https://github.com/spekkionu/tactician-container-selfhandling/blob/master/LICENSE.md)[![Code Coverage](https://camo.githubusercontent.com/2b35d2313ce722093bc86d66f5bf8a228279b25fccb3e459892ce1a3e9724fbd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370656b6b696f6e752f74616374696369616e2d636f6e7461696e65722d73656c6668616e646c696e672f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spekkionu/tactician-container-selfhandling/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b938d63fae2025dadcdf0ee31f7f438f27c94c42614449a8848d40e49ec86fff/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370656b6b696f6e752f74616374696369616e2d636f6e7461696e65722d73656c6668616e646c696e672f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spekkionu/tactician-container-selfhandling/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/37f3e73ef161e67d3fce8589f90892442a2791e0c2cc5d69ff31717739bc453e/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f36653364616537302d623032362d343532652d393266642d6430643237623036356161632f6d696e692e706e67)](https://insight.sensiolabs.com/projects/6e3dae70-b026-452e-92fd-d0d27b065aac)

Install
-------

[](#install)

Via Composer

```
$ composer require spekkionu/tactician-container-selfhandling
```

If you want to use the container aware commands you will also need to install `league/container`

Usage
-----

[](#usage)

### Add MiddleWare

[](#add-middleware)

```
use League\Tactician\CommandBus;
use Spekkionu\Tactician\SelfExecuting\SelfExecutionMiddleware;

$commandBus = new CommandBus([
    // any other pre-execution middleware
    new SelfExecutionMiddleware(),
    // other middleware to handle non-self-executing commands
    // any other post-execution middleware
]);
```

### Create a Command

[](#create-a-command)

Your commands must implement `Spekkionu\Tactician\SelfExecuting\SelfExecutingCommand` and have a handle() method.

The handle method must have no parameters.

```
use Spekkionu\Tactician\SelfExecuting\SelfExecutingCommand;

/**
 * Class ExampleSelfExecutingCommand
 */
class ExampleSelfExecutingCommand implements SelfExecutingCommand
{
    /**
     * @return string
     */
    public function handle()
    {
        // do work here
    }
}
```

### Run Command

[](#run-command)

```
$commandBus->handle(new ExampleSelfExecutingCommand());
```

Container-Aware Self-Executing Commands
---------------------------------------

[](#container-aware-self-executing-commands)

Container aware commands will have dependencies injected into the `handle()` method from `league/container`.

```
use League\Container\Container;
use League\Tactician\CommandBus;
use Spekkionu\Tactician\SelfExecuting\SelfExecutionMiddleware;

// Setup the Container
$container = new Container();
$container->delegate(
    new \League\Container\ReflectionContainer
);
$container->add('Logger', function() {
    return new Logger();
});

// Setup the command bus
$commandBus = new CommandBus([
    // any other pre-execution middleware
    new ContainerAwareSelfExecutionMiddleware($container),
    // other middleware to handle non-self-executing commands
    // any other post-execution middleware
]);
```

```
use Spekkionu\Tactician\SelfExecuting\SelfExecutingCommand;

/**
 * Class ExampleSelfExecutingCommand
 */
class ExampleSelfExecutingCommand implements SelfExecutingCommand
{
    /**
     * The logger will be injected automatically
     * @return string
     */
    public function handle(Logger $logger)
    {
        $logger->log('log message');
    }
}
```

```
$commandBus->handle(new ExampleSelfExecutingCommand());
```

Testing
-------

[](#testing)

```
$ composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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

Every ~56 days

Total

2

Last Release

3478d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f47e67812cdd677cc4fd612e175bb651c2ae35e39d50c7592a815bf515cb12e5?d=identicon)[spekkionu](/maintainers/spekkionu)

---

Top Contributors

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

---

Tags

command-busphptactician

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/spekkionu-tactician-container-selfhandling/health.svg)

```
[![Health](https://phpackages.com/badges/spekkionu-tactician-container-selfhandling/health.svg)](https://phpackages.com/packages/spekkionu-tactician-container-selfhandling)
```

###  Alternatives

[phpdocumentor/phpdocumentor

Documentation Generator for PHP

4.4k3.1M906](/packages/phpdocumentor-phpdocumentor)[hubspot/api-client

Hubspot API client

24016.2M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)[concrete5/core

Concrete – an open source content management system.

20163.8k49](/packages/concrete5-core)

PHPackages © 2026

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