PHPackages                             tourze/symfony-aop-pool-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/symfony-aop-pool-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tourze/symfony-aop-pool-bundle
==============================

Symfony AOP connection pool bundle for automatic resource pooling

1.0.1(6mo ago)026MITPHPCI passing

Since Apr 17Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/tourze/symfony-aop-pool-bundle)[ Packagist](https://packagist.org/packages/tourze/symfony-aop-pool-bundle)[ RSS](/packages/tourze-symfony-aop-pool-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (24)Versions (14)Used By (0)

AopPoolBundle
=============

[](#aoppoolbundle)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/bd5f66b6d5b6ada9d5254b87b86cbd209c0f34def822612a3b6a54f56434bb1a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f73796d666f6e792d616f702d706f6f6c2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/symfony-aop-pool-bundle)[![Total Downloads](https://camo.githubusercontent.com/83fe4c5fa73c40c5d1bb64ed28d113c6b64aff94735d39fe857e387d0fe0c5f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f73796d666f6e792d616f702d706f6f6c2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/symfony-aop-pool-bundle)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/407cae97f462622b426bac8a038a78696841ce2f26cf8caaf5059c90b8f729b7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c75652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/symfony-aop-pool-bundle)[![Code Coverage](https://camo.githubusercontent.com/25302785664d5a8cdcf76f70ff42adf08dd5b6b917d810c411858f48be62149a/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f7068702d6d6f6e6f7265706f2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/tourze/php-monorepo)

AopPoolBundle is a Symfony bundle for automatic connection pooling using AOP (Aspect-Oriented Programming). It provides efficient resource pooling for Redis, database, and custom services, improving performance and resource utilization.

Features
--------

[](#features)

- Automatic lifecycle management for connections (borrow/return)
- Built-in Redis and Doctrine DBAL connection pools
- Custom poolable services via `#[ConnectionPool]` attribute
- Connection health checks and resource recycling
- Lazy initialization, auto-reconnect, and retry support
- Detailed logging and debug support
- Compatible with FPM and Workerman environments

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

[](#installation)

- Requires PHP 8.1+, Symfony 6.4+

```
composer require tourze/symfony-aop-pool-bundle
```

Quick Start
-----------

[](#quick-start)

### 1. Mark Custom Service for Pooling

[](#1-mark-custom-service-for-pooling)

```
use Tourze\Symfony\AopPoolBundle\Attribute\ConnectionPool;

#[ConnectionPool]
class YourService {
    private $connection;
    public function doSomething() {
        // Connection is automatically fetched from the pool
        $result = $this->connection->query(...);
        return $result;
    }
}
```

### 2. Redis Connection Pool

[](#2-redis-connection-pool)

Redis clients are automatically pooled, no extra configuration required:

```
class YourService {
    public function __construct(private \Redis $redis) {}
    public function doSomething() {
        return $this->redis->get('key');
    }
}
```

### 3. Database Connection Pool

[](#3-database-connection-pool)

Doctrine DBAL connections are automatically pooled:

```
use Doctrine\DBAL\Connection;
class YourService {
    public function __construct(private Connection $connection) {}
    public function doSomething() {
        return $this->connection->executeQuery('SELECT ...');
    }
}
```

Services Automatically Pooled
-----------------------------

[](#services-automatically-pooled)

- All services tagged as `snc_redis.client`
- All `doctrine.dbal.*_connection` services
- All services with the `#[ConnectionPool]` attribute

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

[](#configuration)

Add the following to your `.env` if you need to customize:

```
SERVICE_POOL_DEFAULT_SIZE=500
SERVICE_POOL_CLEANUP_INTERVAL=60
SERVICE_POOL_CONNECTION_LIFETIME=60
SERVICE_POOL_CHECK_REDIS_CONNECTION=0
DEBUG_ConnectionPoolAspect=true
```

Performance &amp; Debugging Tips
--------------------------------

[](#performance--debugging-tips)

- Pool only necessary services, set pool size appropriately
- Enable debug logs to monitor pool usage
- Ensure connections are properly released

Notes &amp; Limitations
-----------------------

[](#notes--limitations)

- Connections are automatically returned to the pool at the end of each request
- Pool health checks regularly recycle a small portion of connections to prevent resource exhaustion
- Default pool size: 500 (configurable)
- Max retry attempts = pool size + 1
- Pool switching in transactions is not supported
- Some special services may not be suitable for pooling
- StopWorkerException is thrown if connection fetch fails; automatic retry supported
- Reconnect attempts and intervals are configurable
- Works well in both short-lived (FPM) and long-lived (Workerman) process environments

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

- Please use Issues for bug reports and feature requests
- Pull Requests are welcome; ensure tests and code style pass
- Follow PSR standards

License
-------

[](#license)

MIT License © Tourze

Changelog
---------

[](#changelog)

See \[CHANGELOG.md\] if available.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance71

Regular maintenance activity

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 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

Every ~16 days

Recently: every ~47 days

Total

13

Last Release

192d ago

Major Versions

0.1.1 → 1.0.02025-11-01

### Community

Maintainers

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

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-symfony-aop-pool-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-symfony-aop-pool-bundle/health.svg)](https://phpackages.com/packages/tourze-symfony-aop-pool-bundle)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)

PHPackages © 2026

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