thephpleague/tactician-doctrine

Name: tactician-doctrine

Owner: The League of Extraordinary Packages

Description: Tactician plugins for the Doctrine ORM, primarily transactions

Created: 2015-02-27 16:30:28.0

Updated: 2018-05-23 06:54:57.0

Pushed: 2018-04-13 10:06:58.0

Homepage:

Size: 32

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

tactician-doctrine

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.

Setup

Via Composer

mposer require league/tactician-doctrine

Next, add the ORM\TransactionMiddleware to your CommandBus:

mandBus = 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, don't forget to add the Doctrine middleware to your Symfony config:

ician:
commandbus:
    default:
        middleware:
         - tactician.middleware.locking
         - tactician.middleware.doctrine
         - tactician.middleware.command_handler
Testing
vendor/bin/phpunit
Security

Disclosure information can be found on the main Tactician repo.

License

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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.