PHPackages                             xiaoma404/laravel-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. xiaoma404/laravel-tactician

ActiveLibrary

xiaoma404/laravel-tactician
===========================

Laravel implementation of the Tactician Command Bus, fork from vestin/laravel-tactician

1.0.4(3y ago)0237MITPHPPHP &gt;=5.6.0

Since Sep 8Pushed 3y agoCompare

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

READMEChangelog (3)Dependencies (5)Versions (21)Used By (0)

Laravel Tactician
=================

[](#laravel-tactician)

Laravel Tactician in an implementation of the Command Bus Tactician by Ross Tuck.

[![Build Status](https://camo.githubusercontent.com/c6a802bc1ca742e2bc011deb5f0bb6c043bb7c0dc652279bf4111ab20df3d76c/68747470733a2f2f7472617669732d63692e6f72672f6a6f73656c666f6e736563612f6c61726176656c2d74616374696369616e2e737667)](https://travis-ci.org/joselfonseca/laravel-tactician)[![Code Coverage](https://camo.githubusercontent.com/8dbeaab5d04fe13d342e9faaeea7e388e4792a071d33b3eb533ad943b87e4ad0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6f73656c666f6e736563612f6c61726176656c2d74616374696369616e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/joselfonseca/laravel-tactician/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/9717e82076d408bd640f884d3f8c8156ef401ecc0edaa453788548733ed0e1b1/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73656c666f6e736563612f6c61726176656c2d74616374696369616e2f646f776e6c6f6164732e737667)](https://packagist.org/packages/joselfonseca/laravel-tactician)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/de361acc87c8ecd5e7595892bb25c69e206e58364ecf2faeb716d7ad4a5cc93e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6f73656c666f6e736563612f6c61726176656c2d74616374696369616e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/joselfonseca/laravel-tactician/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/b424dbce6e83e598f25d05779c44890d54cfbad7dc0d9293d6211205af95945a/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f34626566353832632d313837642d346362652d626366382d3032316437643665356635642f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/4bef582c-187d-4cbe-bcf8-021d7d6e5f5d)

Installation
------------

[](#installation)

To install this update your composer.json run `composer require joselfonseca/laravel-tactician`

#### &gt;= laravel5.5

[](#-laravel55)

ServiceProvider will be attached automatically.

#### Other

[](#other)

Once the dependencies have been downloaded, add the service provider to your config/app.php file:

```
    'providers' => [
        ...
        Joselfonseca\LaravelTactician\Providers\LaravelTacticianServiceProvider::class
        ...
    ]
```

You are done with the installation!

Usage
-----

[](#usage)

To use the command bus you can resolve the bus from the laravel container like so:

```
    $bus = app('Joselfonseca\LaravelTactician\CommandBusInterface');
```

Or you can inject it into a class constructor:

```
    use Joselfonseca\LaravelTactician\CommandBusInterface;

    class MyController extends BaseController
    {

        public function __construct(CommandBusInterface $bus)
        {
            $this->bus = $bus;
        }

    }
```

Once you have the bus instance you can add your handler for the command to be dispatched:

```
    $bus->addHandler('SomeCommand', 'SomeHandler');
```

Now you can dispatch the command with the middleware:

```
    // first parameter is the class name of the command
    // Second parameter is an array of input data to be mapped to the command
    // Third parameter is an array of middleware class names to be added to the stack
    $bus->dispatch('SomeCommand', [], []);
```

You can map the input data array of the Command's *constructor* with a plain list of arguments or the array itself. For example:

```
    // Send parameters in an array of input data ...
    $bus->dispatch('SomeCommand', [
        'propertyOne'   => 'One',
        'propertyTwo'   => 'Two',
        'propertyThree' => 'Three',
    ], []);

    // ... and receive them as individual parameters ...
    Class SomeCommand {
        public function __construct($propertyOne = 'A', $propertyTwo = 'B', $propertyThree = 'C'){
            //...
        }
    }

```

Of course, you can use default values!

For more information about the usage of the tactician command bus please visit .

Example
-------

[](#example)

Check out this example of the package implemented in a simple create order command .

Bindings
--------

[](#bindings)

You can configure the bindings for the locator, inflector, extractor and default bus by publishing the config file like so:

```
    php artisan vendor:publish
```

Then you can modify each class name and they will be resolved from the laravel container:

```
    return [
        // The locator to bind
        'locator' => 'Joselfonseca\LaravelTactician\Locator\LaravelLocator',
        // The inflector to bind
        'inflector' => 'League\Tactician\Handler\MethodNameInflector\HandleInflector',
        // The extractor to bind
        'extractor' => 'League\Tactician\Handler\CommandNameExtractor\ClassNameExtractor',
        // The bus to bind
        'bus' => 'Joselfonseca\LaravelTactician\Bus'
    ];
```

Generators
----------

[](#generators)

You can generate Commands and Handlers automatically using artisan:

```
artisan make:tactician:command Foo
artisan make:tactician:handler Foo

```

This will create FooCommand and FooHandler and place them in the `app/Commands` folder, please note that the words `Command` and `Handler` will be added to the class names respectively, so in the avobe example the clases created will be `FooCommand` and `FooHandler`.

To run both at once:

```
artisan make:tactician Foo

```

Middleware included
-------------------

[](#middleware-included)

Laravel tactician includes some useful middleware you can use in your commands.

- Database Transactions: This Middleware will run the command inside a database transaction, if any exception is thrown the transaction won't be committed and the database will stay intact, you can find this middleware in `Joselfonseca\LaravelTactician\Middleware\DatabaseTransactions`.

Change log
----------

[](#change-log)

Please see the releases page

Tests
-----

[](#tests)

To run the tests in this package, navigate to the root folder of the project and run:

```
    composer install
```

Then

```
    vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email jose at ditecnologia dot com instead of using the issue tracker.

Credits
-------

[](#credits)

- [Jose Luis Fonseca](https://github.com/joselfonseca)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 80.2% 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 ~135 days

Recently: every ~278 days

Total

20

Last Release

1327d ago

Major Versions

0.5.1 → 1.0.02019-09-04

PHP version history (2 changes)v0.1.0PHP &gt;=5.5.0

0.4.0PHP &gt;=5.6.0

### Community

Maintainers

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

---

Top Contributors

[![joselfonseca](https://avatars.githubusercontent.com/u/2046653?v=4)](https://github.com/joselfonseca "joselfonseca (65 commits)")[![timbroder](https://avatars.githubusercontent.com/u/121503?v=4)](https://github.com/timbroder "timbroder (5 commits)")[![jeffagostinho](https://avatars.githubusercontent.com/u/6639259?v=4)](https://github.com/jeffagostinho "jeffagostinho (3 commits)")[![kpicaza](https://avatars.githubusercontent.com/u/1093654?v=4)](https://github.com/kpicaza "kpicaza (2 commits)")[![xiaoma404](https://avatars.githubusercontent.com/u/55519684?v=4)](https://github.com/xiaoma404 "xiaoma404 (2 commits)")[![lloy0076](https://avatars.githubusercontent.com/u/1174532?v=4)](https://github.com/lloy0076 "lloy0076 (1 commits)")[![jcrowe206](https://avatars.githubusercontent.com/u/928788?v=4)](https://github.com/jcrowe206 "jcrowe206 (1 commits)")[![ralbear](https://avatars.githubusercontent.com/u/3120856?v=4)](https://github.com/ralbear "ralbear (1 commits)")[![Vestin](https://avatars.githubusercontent.com/u/13653162?v=4)](https://github.com/Vestin "Vestin (1 commits)")

---

Tags

laravelcommand bustacticianlaravel-tactician

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xiaoma404-laravel-tactician/health.svg)

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

###  Alternatives

[league/tactician-doctrine

Plugins for Tactician commands using Doctrine, like wrapping every command in a transaction

583.1M9](/packages/league-tactician-doctrine)[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)[jildertmiedema/laravel-tactician

Tactician for laravel 8+

105.0k](/packages/jildertmiedema-laravel-tactician)

PHPackages © 2026

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