PHPackages                             axsy/transactional-bundle - 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. axsy/transactional-bundle

ActiveSymfony-bundle

axsy/transactional-bundle
=========================

Provides transactional wrapper for the controllers and services

1.0.0(13y ago)020MITPHP

Since May 4Pushed 13y ago1 watchersCompare

[ Source](https://github.com/axsy/TransactionalBundle)[ Packagist](https://packagist.org/packages/axsy/transactional-bundle)[ Docs](https://github.com/axsy/TransactionalBundle)[ RSS](/packages/axsy-transactional-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

AxsyTransactionalBundle
=======================

[](#axsytransactionalbundle)

This bundle provides transactional wrapper for the controllers and services. In the most simple case the usage is as simple as adding the @Transactionable annotation to the Controller action:

```
use Axsy\TransactionalBundle\Annotation\Transactionable;

// Acme/SomeBundle/Controllers/SomeController.php
class SomeController extends Controller
{
    /**
     * @Transactionable
     */
    public function performRollbackOnExceptionAction()
    {
        // Persist some changes to the database using Doctrine DBAL or Doctrine ORM, whatever
        // ...
        // ...

        // Throw an exceptions
        // All changes performed upper will be rolled back
        throw new \RuntimeException();
    }
}
```

or to some service method:

```
use Axsy\TransactionalBundle\Annotation\Transactionable;

// Acme/SomeBundle/SomeService.php
class SomeService
{
    /**
     * @Transactionable
     */
    public function performRollbackOnException()
    {
        // ...
    }

    // ...
    // ...
}
```

There are some options to customize the @Transactionable behavior, see below.

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

[](#installation)

This bundle can be installed via `composer`. Just add the following lines to the `comsposer.json`

```
// composer.json
{
    // ...
    require: {
        // ...
        "axsy/transactional-bundle": "dev-master"
    }
}
```

Please replace `dev-master` in the snippet above with the latest stable branch, for example `1.0.*`. Please check the tags on Github for which versions are available.

Then, you can install the new dependencies by running Composer's `update` command from the directory where your `composer.json` file is located:

```
php composer.phar update
```

Now, Composer will automatically download all required files, and install them for you. All that is left to do is to update your `AppKernel.php` file, and register the new bundle:

```
// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Axsy\TransactionalBundle\AxsyTransactionalBundle(),
    // ...
);
```

Please make sure, that `JMS\AopBundle\JMSAopBundle` and `JMS\DiExtraBundle\JMSDiExtraBundle` are registered too. They're already registered in the Symfony Standard Edition distribution out of the box.

Configuration
-------------

[](#configuration)

This bundle allows to set the default Doctrine DBAL connection to be used and\\or default transaction isolation level. By defaut the following settings are accepted:

```
axsy_transactional:
    default_connection:   default

    # Supported isolations are read_uncommitted, read_committed, repeatable_read, serializable
    default_isolation:    read_committed
```

@Transactionable
----------------

[](#transactionable)

This annotation allows to override the default connection name and transaction isolation level:

```
use Axsy\TransactionalBundle\Annotation\Transactionable;

// Acme/SomeBundle/SomeService.php
class SomeService
{
    /**
     * Transactionable(connection="other", isolation="read_uncommitted")
     */
    public function performRollbackOnException()
    {
        // ...
    }
}
```

Also you can explicitly enumerate the class names of the exceptions that will be 'transparent' for the transaction and it will be committed successfully:

```
use Axsy\TransactionalBundle\Annotation\Transactionable;

// Acme/SomeBundle/Controllers/SomeController.php
class SomeController extends Controller
{
    /**
     * @Transactionable(noRollbackFor={"Symfony\Component\HttpKernel\Exception\NotFoundHttpException"})
     */
    public function performCommitOnNotFoundHttpExceptionAction()
    {
        // ...
    }
}
```

and vice versa:

```
use Axsy\TransactionalBundle\Annotation\Transactionable;

// Acme/SomeBundle/SomeService.php
class SomeService
{
    /**
     * @Transactionable(rollbackFor={"Acme\SomeBundle\Exceptions\VeryBadException"})
     */
    public function performRollbackOnVeryBadExceptionOnly()
    {
        // ...
    }
}
```

@Transactionable annotation can be defined on the class level. This way all methods of the controller/service will be annotated silently too:

```
use Axsy\TransactionalBundle\Annotation\Transactionable;

// Acme/SomeBundle/Controllers/SomeController.php
/**
 * @Transactionable(noRollbackFor={"Symfony\Component\HttpKernel\Exception\NotFoundHttpException"})
 */
class SomeController extends Controller
{
    public function performCommitOnNotFoundHttpExceptionAction()
    {
        // ...
    }

    public function thisTooAction()
    {
        // ...
    }
}
```

It is possible to override some settings of globally defined annotation on the method level:

```
use Axsy\TransactionalBundle\Annotation\Transactionable;

// Acme/SomeBundle/SomeService.php
/**
 * @Transactionable(rollbackFor={"Acme\SomeBundle\Exceptions\VeryBadException"})
 */
class SomeService
{
    public function performRollbackOnVeryBadExceptionOnlyOnDefaultConnection()
    {
        // ...
    }

    /**
     * @Transactionable(connection="other")
     */
    public function performRollbackOnVeryBadExceptionOnlyOnOtherConnection()
    {
        // ...
    }
}
```

Tests
-----

[](#tests)

You can simply run the tests for the bundle, run the following commands from the root of the application:

```
cp vendor/axsy/transactional-bundle/Axsy/TransactionalBundle/phpunit.xml.desc vendor/axsy/transactional-bundle/Axsy/TransactionalBundle/phpunit.xml
phpunit -c vendor/axsy/transactional-bundle/Axsy/TransactionalBundle/phpunit.xml
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

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

Unknown

Total

1

Last Release

4756d ago

### Community

Maintainers

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

---

Top Contributors

[![axsy](https://avatars.githubusercontent.com/u/1961299?v=4)](https://github.com/axsy "axsy (30 commits)")

---

Tags

annotationstransaction

### Embed Badge

![Health badge](/badges/axsy-transactional-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/axsy-transactional-bundle/health.svg)](https://phpackages.com/packages/axsy-transactional-bundle)
```

###  Alternatives

[jms/security-extra-bundle

Enhances the Symfony2 Security Component by adding several new features

2628.1M59](/packages/jms-security-extra-bundle)[jms/di-extra-bundle

Allows to configure dependency injection using annotations

32813.3M88](/packages/jms-di-extra-bundle)[jms/aop-bundle

Adds AOP capabilities to Symfony2

20413.7M22](/packages/jms-aop-bundle)[tobion/openapi-symfony-routing

Loads routes in Symfony based on OpenAPI/Swagger annotations

4219.5k](/packages/tobion-openapi-symfony-routing)[superbrave/gdpr-bundle

A Symfony bundle for using entity annotations according to GDPR requirements and anonymizing/exporting data

1120.0k](/packages/superbrave-gdpr-bundle)[widop/framework-extra-bundle

An extension to Symfony2 FrameworkBundle that adds annotation configuration for Controller classes.

111.3k](/packages/widop-framework-extra-bundle)

PHPackages © 2026

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