PHPackages                             aeatech/transaction-manager-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. [Database &amp; ORM](/categories/database)
4. /
5. aeatech/transaction-manager-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

aeatech/transaction-manager-bundle
==================================

Symfony bundle that glues AEATech Transaction Manager into the Symfony ecosystem, providing Doctrine DBAL integration, multiple transaction managers.

1.0.0(5mo ago)00MITPHPPHP &gt;=8.2CI passing

Since Jan 11Pushed 5mo agoCompare

[ Source](https://github.com/AEATech/transaction-manager-bundle)[ Packagist](https://packagist.org/packages/aeatech/transaction-manager-bundle)[ RSS](/packages/aeatech-transaction-manager-bundle/feed)WikiDiscussions main Synced today

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

AEATech Transaction Manager Bundle
==================================

[](#aeatech-transaction-manager-bundle)

[![Code Coverage](.build/coverage_badge.svg)](.build/coverage_badge.svg)

Symfony bundle that integrates [AEATech Transaction Manager](https://github.com/AEATech/transaction-manager-core) into the Symfony ecosystem.

Features
--------

[](#features)

- **Multiple Transaction Managers**: Configure different managers for different database connections.
- **Doctrine DBAL Integration**: Out-of-the-box support for Doctrine connections via `aeatech/transaction-manager-doctrine-adapter`.
- **Platform-Specific Factories**: Convenient interfaces for creating MySQL and PostgreSQL transactions.
- **Advanced Retry Policies**: Customizable exponential backoff strategies with jitter.
- **PHP Attributes Support**: Easy autoconfiguration for custom heuristics, classifiers, and adapters.
- **Lazy Loading**: Managers are initialized only when first accessed via a service locator.

---

Table of Contents
-----------------

[](#table-of-contents)

- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Configuration](#configuration)
    - [YAML Configuration](#yaml-configuration)
    - [Autoconfiguration with PHP Attributes](#autoconfiguration-with-php-attributes)
- [Usage](#usage)
    - [Basic Example](#basic-example)
    - [Autowiring](#autowiring)
    - [Using Registry](#using-registry)
- [Testing](#testing)
- [Development](#development)

---

Prerequisites
-------------

[](#prerequisites)

- PHP 8.2 or higher
- Symfony 6.4 or 7.x

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

[](#installation)

```
composer require aeatech/transaction-manager-bundle
```

Depending on your database, you also need to install the corresponding driver package:

### For MySQL

[](#for-mysql)

```
composer require aeatech/transaction-manager-mysql
```

### For PostgreSQL

[](#for-postgresql)

```
composer require aeatech/transaction-manager-postgresql
```

### For Doctrine DBAL (Adapter)

[](#for-doctrine-dbal-adapter)

```
composer require aeatech/transaction-manager-doctrine-adapter
```

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

[](#configuration)

The bundle allows you to configure multiple transaction managers, each with its own platform and connection.

### YAML Configuration

[](#yaml-configuration)

```
# config/packages/aea_tech_transaction_manager.yaml
aea_tech_transaction_manager:
  default_manager: main
  managers:
    main:
      platform: mysql
      connection_adapter:
        doctrine:
          connection: default # Connection name from doctrine.yaml
      retry_policy:
        max_retries: 5       # Default: 7
        backoff:
          base_delay_ms: 100 # Default: 150
          max_delay_ms: 5000 # Default: 2000
          multiplier: 2.0    # Default: 2.0
          jitter_ms: 100     # Default: 250

    analytics:
      platform: postgres
      connection_adapter: 'App\PostgresCustomConnectionAdapter'
      execution_plan_builder:
        deferred_build_resolver:
          strategy: caching # Options: "caching" (default) or "reflection"
      error_classifier:
        heuristics: 'App\PostgresCustomHeuristics'
      retry_policy:
        max_retries: 3
        backoff: 'App\PostgresCustomBackoff'
```

#### Configuration Options

[](#configuration-options)

- **Connection Adapter**:
    - `doctrine`: Requires `aeatech/transaction-manager-doctrine-adapter`. Specify the connection name.
    - `service`: Provide a service ID implementing `ConnectionInterface`.
- **Execution Plan Builder**:
    - `deferred_build_resolver.strategy`: How to detect transactions that need deferred building.
    - `deferred_build_resolver.service`: Custom service ID implementing `DeferredBuildResolverInterface`.
- **Error Classifier**:
    - `service`: Custom service ID implementing `ErrorClassifierInterface`.
    - `heuristics`: Custom service ID implementing `DatabaseErrorHeuristicsInterface`.

### Autoconfiguration with PHP Attributes

[](#autoconfiguration-with-php-attributes)

The bundle provides PHP attributes to configure certain services automatically without modifying the YAML configuration. This is the recommended way for most use cases.

> **Note:** If you configure a component (like heuristics or a classifier) for a manager both in YAML and via an attribute, an `InvalidConfigurationException` will be thrown.

#### Available Attributes

[](#available-attributes)

All attributes accept a `managerNames` parameter (string or array of strings).

AttributeInterfaceDescription`#[AsHeuristics]``DatabaseErrorHeuristicsInterface`Overrides platform-specific error heuristics.`#[AsErrorClassifier]``ErrorClassifierInterface`Provides custom error classification logic.`#[AsDeferredBuildResolver]``DeferredBuildResolverInterface`Customizes how deferred builds are detected.`#[AsConnectionAdapter]``ConnectionInterface`Provides a custom database connection adapter.`#[AsRetryPolicyBackoff]``BackoffStrategyInterface`Implements a custom retry backoff strategy.**Example:**

```
use AEATech\TransactionManager\DatabaseErrorHeuristicsInterface;
use AEATech\TransactionManagerBundle\Attribute\AsHeuristics;

#[AsHeuristics(managerNames: 'main')]
class MyCustomHeuristics implements DatabaseErrorHeuristicsInterface
{
    public function isConnectionIssue(?string $sqlState, ?int $driverCode, string $message): bool
    {
        // your logic
    }

    public function isTransientIssue(?string $sqlState, ?int $driverCode, string $message): bool
    {
        // your logic
    }
}
```

---

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

The main way to interact with the bundle is through the `TransactionManagerInterface` and platform-specific factories.

```
use AEATech\TransactionManager\TransactionManagerInterface;
use AEATech\TransactionManager\MySQL\MySQLTransactionsFactoryInterface;

class RegisterUserService
{
    public function __construct(
        private TransactionManagerInterface $tm,
        private MySQLTransactionsFactoryInterface $factory
    ) {}

    public function register(string $email): void
    {
        // Create a transaction (this doesn't execute anything yet)
        $tx = $this->factory->createInsert('users', ['email' => $email]);

        // Run the transaction (includes retries on transient errors)
        $this->tm->run($tx);
    }
}
```

### Autowiring

[](#autowiring)

#### Default Manager

[](#default-manager)

```
public function __construct(TransactionManagerInterface $tm)
{
    // Injects the manager configured in 'default_manager'
}
```

#### Specific Manager

[](#specific-manager)

```
use Symfony\Component\DependencyInjection\Attribute\Autowire;

public function __construct(
    #[Autowire(service: 'aea_tech_transaction_manager.analytics')]
    TransactionManagerInterface $analyticsTm
) {}
```

#### Transaction Factories

[](#transaction-factories)

The bundle automatically creates aliases for platform-specific transaction factories for the default manager's platform.

```
use AEATech\TransactionManager\MySQL\MySQLTransactionsFactoryInterface;

public function __construct(MySQLTransactionsFactoryInterface $factory) { /* ... */ }
```

### Using Transaction Manager Registry

[](#using-transaction-manager-registry)

If you need to select a manager at runtime (e.g., in a worker or for multi-tenant applications), use `TransactionManagerRegistryInterface`.

```
use AEATech\TransactionManagerBundle\TransactionManagerRegistryInterface;

class MaintenanceCommand
{
    public function __construct(private TransactionManagerRegistryInterface $registry) {}

    public function execute(): void
    {
        // Get a specific manager by name
        $tm = $this->registry->getManager('analytics');

        // Get all registered manager names
        $names = $this->registry->getManagerNames();

        // Get the default manager name
        $default = $this->registry->getDefaultManagerName();
    }
}
```

---

Testing
-------

[](#testing)

When writing unit tests for your services, you should mock `TransactionManagerInterface`.

Using **Mockery**:

```
public function testRegister(): void
{
    $tm = \Mockery::mock(TransactionManagerInterface::class);
    $factory = \Mockery::mock(MySQLTransactionsFactoryInterface::class);

    $tx = \Mockery::mock(\AEATech\TransactionManager\TransactionInterface::class);
    $factory->shouldReceive('createInsert')->andReturn($tx);

    // Expect the transaction to be run
    $tm->shouldReceive('run')->with($tx)->once();

    $service = new RegisterUserService($tm, $factory);
    $service->register('test@example.com');
}
```

---

Development
-----------

[](#development)

### Start the Environment

[](#start-the-environment)

```
docker-compose -p aeatech-transaction-manager-bundle -f docker/docker-compose.yml up -d --build
```

### Install Dependencies

[](#install-dependencies)

```
docker-compose -p aeatech-transaction-manager-bundle -f docker/docker-compose.yml exec php-cli-8.2 composer install
```

### Run Tests

[](#run-tests)

```
# Run tests for all supported PHP versions
for v in 8.2 8.3 8.4; do \
    echo "Testing PHP $v..."; \
    docker-compose -p aeatech-transaction-manager-bundle -f docker/docker-compose.yml exec php-cli-$v vendor/bin/phpunit || break; \
done
```

```
# PHP 8.4
docker-compose -p aeatech-transaction-manager-bundle -f docker/docker-compose.yml exec php-cli-8.4 vendor/bin/phpunit
```

### PHPStan

[](#phpstan)

```
docker-compose -p aeatech-transaction-manager-bundle -f docker/docker-compose.yml exec php-cli-8.4 vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=1G
```

### Stop the Environment

[](#stop-the-environment)

```
docker-compose -p aeatech-transaction-manager-bundle -f docker/docker-compose.yml down -v
```

---

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance70

Regular maintenance activity

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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

173d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/249475575?v=4)[aeatech2025](/maintainers/aeatech2025)[@aeatech2025](https://github.com/aeatech2025)

---

Top Contributors

[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")[![Shahelm](https://avatars.githubusercontent.com/u/5507279?v=4)](https://github.com/Shahelm "Shahelm (1 commits)")

---

Tags

bundledatabasetransactionaeatechtransaction-manager

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/aeatech-transaction-manager-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/aeatech-transaction-manager-bundle/health.svg)](https://phpackages.com/packages/aeatech-transaction-manager-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M386](/packages/easycorp-easyadmin-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[chameleon-system/chameleon-base

The Chameleon System core.

1028.6k5](/packages/chameleon-system-chameleon-base)

PHPackages © 2026

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