PHPackages                             madewithlove/tactician-laravel - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. madewithlove/tactician-laravel

Abandoned → [league/tactician](/?search=league%2Ftactician)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

madewithlove/tactician-laravel
==============================

Integrate tactician with Laravel 5

1.0.3(6y ago)2062.6k↓50%6[1 issues](https://github.com/madewithlove/tactician-laravel/issues)MITPHPPHP &gt;=7.2

Since Dec 23Pushed 6y ago12 watchersCompare

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

READMEChangelog (4)Dependencies (8)Versions (7)Used By (0)

madewithlove/tactician-laravel
==============================

[](#madewithlovetactician-laravel)

[![Build Status](https://camo.githubusercontent.com/c8bcb101f587dcdcbd0ff277c89d6c07294528bd7174bcdadd13f943e756e4a0/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f6d616465776974686c6f76652f74616374696369616e2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/madewithlove/tactician-laravel)[![Latest Stable Version](https://camo.githubusercontent.com/9e0539c50fb8d7ed9d710dc52f7855a2a8c841e7f733b746a357d51fd4a66f69/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616465776974686c6f76652f74616374696369616e2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/madewithlove/tactician-laravel)[![Total Downloads](https://camo.githubusercontent.com/322436df03f7b0d08ecd24d7f1eedccbc2afd60a44e0f394a80cc37dbcd8686a/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d616465776974686c6f76652f74616374696369616e2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/madewithlove/tactician-laravel)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/317fdf25e23ea0673291178a6aae6f99c24dab9726ceb2ec01c1e71a4fae31ee/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d616465776974686c6f76652f74616374696369616e2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/madewithlove/tactician-laravel)[![Code Coverage](https://camo.githubusercontent.com/9ce4e3fd606506f3fc351fb0b03f6c6fecb095dca105e5f1983ef2303329b4d2/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6d616465776974686c6f76652f74616374696369616e2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/madewithlove/tactician-laravel)

Introduction
------------

[](#introduction)

This packages is a replacement for Laravel 5's default command bus using [tactician](http://tactician.thephpleague.com).

### Default middleware

[](#default-middleware)

- [LockingMiddleware](http://tactician.thephpleague.com/plugins/locking-middleware/) (block commands from running inside commands)
- TransactionMiddleware (Run all commands in a database transaction and rolls back incase of failure)

### Command Handling

[](#command-handling)

By default commands will be resolved as followed:

```
Acme\Jobs\Foo => Acme\Listeners\Foo
Acme\Foo\Jobs\Bar => Acme\Foo\Listeners\Bar

```

All command handlers are resolved out of the [container](http://laravel.com/docs/5.2/container) which mean you can use all kind of Laravel goodies.

Install
-------

[](#install)

```
$ composer require madewithlove/tactician-laravel
```

### Laravel &lt;= 5.4

[](#laravel--54)

Add the service provider to `config/app.php`:

```
Madewithlove\Tactician\ServiceProvider::class,
```

In case you want to tweak the middleware you should publish the package configuration:

```
php artisan vendor:publish --provider="Madewithlove\Tactician\ServiceProvider"
```

Usage
-----

[](#usage)

### Writing commands

[](#writing-commands)

A command always consists out of two parts: the command and the handler.

```
// Products\Jobs\CalculatePriceForQuantity
class CalculatePriceForQuantity
{
    public $price;

    public $amount;

    public function __construct($price, $amount = 1)
    {
        $this->price = $price;
        $this->amount = $amount;
    }
}

use Products\Jobs\CalculatePriceForQuantity as Job;

// Products\Listeners\CalculatePriceForQuantity
class CalculatePriceForQuantity
{
    public function handle(Job $job)
    {
        return $job->amount * $job->price;
    }
}
```

#### Overriding the command handling logic

[](#overriding-the-command-handling-logic)

If you're not happy with the default logic shipped in this package you can overwrite it easily by rebinding the `League\Tactician\Handler\CommandHandlerMiddleware`. You do this by adding the following to your application's service provider, refer to [Tactician's documentation](http://tactician.thephpleague.com/tweaking-tactician/)for options.

```
public function register()
{
    $this->app->bind(CommandHandlerMiddleware::class, function () {
        // Return your own implementation of CommandHandlerMiddleware here.
    });
}
```

Middleware
----------

[](#middleware)

This package includes a couple middleware specific to Laravel, you can choose to use these.

### `TransactionMiddleware`

[](#transactionmiddleware)

This middleware is included by default. It means all your commands are handled inside of a database transaction, and if an error occurs it will rollback the transaction.

It's quite common for a command to throw an exception that is caught higher up the chain so a certain action can be performed (such as displaying an error message) but still perform some kind of database interaction. For cases such as this you can make use of the `Madewithlove\Tactician\Contracts\IgnoresRollback` interface. Simply implement it on your exception and no rollbacks will be performed!

**Note**: This middleware only runs the main database connection in a transaction, if you use multiple connections you will need to come up with a custom solution.

Testing
-------

[](#testing)

```
$ composer test
```

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~337 days

Total

5

Last Release

2443d ago

Major Versions

0.1.0 → 1.0.02016-03-14

PHP version history (2 changes)0.1.0PHP &gt;=5.5.9

1.0.3PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/df052a58ecfa5a07fd2b4cb12bb128ab28ff4b8e82fb0831eab81623b898ddb4?d=identicon)[madewithlove-machine-user](/maintainers/madewithlove-machine-user)

![](https://www.gravatar.com/avatar/041cdc8fc831716b7f56c3ddf84169ea1d97ca91e9ea90b42be88d73c404ff8a?d=identicon)[bramdevries](/maintainers/bramdevries)

![](https://www.gravatar.com/avatar/47020dbad12c7484fcbf5d489573b7d67a3a9f479d7b3f47b314e8bf4372aab5?d=identicon)[WouterSioen](/maintainers/WouterSioen)

---

Top Contributors

[![bramdevries](https://avatars.githubusercontent.com/u/1002245?v=4)](https://github.com/bramdevries "bramdevries (27 commits)")[![guiwoda](https://avatars.githubusercontent.com/u/1625545?v=4)](https://github.com/guiwoda "guiwoda (3 commits)")[![hannesvdvreken](https://avatars.githubusercontent.com/u/1410358?v=4)](https://github.com/hannesvdvreken "hannesvdvreken (2 commits)")[![dieterve](https://avatars.githubusercontent.com/u/313404?v=4)](https://github.com/dieterve "dieterve (1 commits)")[![hiddeco](https://avatars.githubusercontent.com/u/10063039?v=4)](https://github.com/hiddeco "hiddeco (1 commits)")[![jdrieghe](https://avatars.githubusercontent.com/u/12606789?v=4)](https://github.com/jdrieghe "jdrieghe (1 commits)")[![redgluten](https://avatars.githubusercontent.com/u/7190090?v=4)](https://github.com/redgluten "redgluten (1 commits)")

---

Tags

laravel

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[glhd/special

1929.4k](/packages/glhd-special)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

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