Tactician plugins for the Doctrine ORM, primarily transactions
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src RollbackOnlyTransactionMiddleware Apr 8, 2018
tests RollbackOnlyTransactionMiddleware Apr 8, 2018
.gitattributes Added .gitattributes Feb 25, 2016
.gitignore DBAL Transaction Middleware Jan 2, 2017
.scrutinizer.yml Add scrutinizer config Feb 27, 2015
.travis.yml Update .travis.yml Jul 26, 2018
LICENSE.md Update license year Feb 27, 2015
README.md Remove 2 from Symfony, as it also works in Symfony 3 Jun 19, 2017
phpunit.xml.dist Initial import Feb 27, 2015



Latest Version Software License Build Status Quality Score Total Downloads

This package adds plugins for using Tactician with Doctrine components, either the ORM or just DBAL. The main feature is the ability to wrap each command in a separate database transaction.


Via Composer

$ composer require league/tactician-doctrine

Next, add the ORM\TransactionMiddleware to your CommandBus:

$commandBus = new \League\Tactician\CommandBus(
        new TransactionMiddleware($ormEntityManager)

That's it. Each command you execute will now open and close a new transaction.

If a command fires off more commands, be aware that those commands will run in the same transaction as the parent. It is recommended that you run each command as a separate transaction, so to prevent this from happening, use the LockingMiddleware that ships in Tactician core. This will queue the commands up internally until the parent command has completed.

If an exception is raised while handling the command, the transaction is rolled back, the EntityManager closed, and the exception rethrown.

Symfony integration

When using the [tactician-bundle] (https://github.com/thephpleague/tactician-bundle), don't forget to add the Doctrine middleware to your Symfony config:

             - tactician.middleware.locking
             - tactician.middleware.doctrine
             - tactician.middleware.command_handler


$ ./vendor/bin/phpunit


Disclosure information can be found on the main Tactician repo.


The MIT License (MIT). Please see License File for more information.