PHPackages                             tourze/symfony-aop-lock-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. tourze/symfony-aop-lock-bundle

ActiveSymfony-bundle

tourze/symfony-aop-lock-bundle
==============================

A lightweight Symfony bundle providing declarative distributed locking based on AOP (Aspect-Oriented Programming). Easily add locking logic to your methods using attributes, enabling safe concurrency control in distributed environments.

1.0.1(4mo ago)14592MITPHPCI passing

Since Apr 8Pushed 4mo ago1 watchersCompare

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

READMEChangelog (5)Dependencies (15)Versions (6)Used By (2)

Symfony AOP Lock Bundle
=======================

[](#symfony-aop-lock-bundle)

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

[![Latest Version](https://camo.githubusercontent.com/7cba04d7ce95b34c24db3b288e9f709da5a26482714bcada1fd346d1878617d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f73796d666f6e792d616f702d6c6f636b2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/symfony-aop-lock-bundle)[![PHP Version](https://camo.githubusercontent.com/8086f8596b13add3ca950c7c5e591a3c515b0283fbaa53679c3c987654cbec51/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f73796d666f6e792d616f702d6c6f636b2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/symfony-aop-lock-bundle)[![License](https://camo.githubusercontent.com/98ca9734b48489c880e22f1b8f4a906679571555e68047b5c8b8d0eb5be28edb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f73796d666f6e792d616f702d6c6f636b2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/symfony-aop-lock-bundle)[![Build Status](https://camo.githubusercontent.com/73bde22487522fba327175590581e8df078996abfc5a4f6f434bafcecee5c5ca/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f746f75727a652f73796d666f6e792d616f702d6c6f636b2d62756e646c652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/tourze/symfony-aop-lock-bundle)[![Quality Score](https://camo.githubusercontent.com/ff0d35c57ffabf0df525442af56c0956324016309ee7dc1bb33095202afbbe3d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f746f75727a652f73796d666f6e792d616f702d6c6f636b2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tourze/symfony-aop-lock-bundle)[![Coverage Status](https://camo.githubusercontent.com/4de64e4bf617e28e7d5b057f16910307268e7fd58c7fa65134966bbfc806b2e6/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f73796d666f6e792d616f702d6c6f636b2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/symfony-aop-lock-bundle)[![Total Downloads](https://camo.githubusercontent.com/1b0d270dd4e0eed79120c3512994cf2a80ef4d008d12c7ef6bfbb07001d4c544/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f73796d666f6e792d616f702d6c6f636b2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/symfony-aop-lock-bundle)

A lightweight Symfony bundle providing declarative distributed locking based on AOP (Aspect-Oriented Programming). Easily add locking logic to your methods using attributes, enabling safe concurrency control in distributed environments.

Features
--------

[](#features)

- Declarative locking with the `#[Lockable]` attribute
- Customizable lock key with Twig template syntax
- Automatic lock acquire/release (even on exception)
- Seamless integration with Symfony Lock component
- Suitable for distributed/multi-instance deployments

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

[](#installation)

**Requirements:**

- PHP &gt;= 8.1
- Symfony &gt;= 6.4
- Required dependencies: symfony/lock, twig/twig, tourze/symfony-aop-bundle

Install via Composer:

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

Register the bundle in your `config/bundles.php` if not auto-registered:

```
return [
    // ... other bundles
    Tourze\Symfony\AopLockBundle\AopLockBundle::class => ['all' => true],
];
```

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

[](#quick-start)

Annotate your methods with `#[Lockable]`:

```
use Tourze\Symfony\AopLockBundle\Attribute\Lockable;

class OrderService
{
    #[Lockable]
    public function processOrder(string $orderId): void
    {
        // business logic
    }

    #[Lockable(key: "user_{{ userId }}_update")]
    public function updateUserProfile(int $userId, array $data): void
    {
        // business logic
    }
}
```

- The lock key can be customized using method parameters and Twig syntax, e.g. `order_{{ orderId }}`.
- Supported Twig variables: method parameters, `joinPoint.method`, `joinPoint.class`, etc.

Documentation
-------------

[](#documentation)

- [API Reference](#)
- **Configuration:**
    - Default lock timeout: 30 seconds
    - All lock/unlock logic is handled automatically by the aspect
- **Advanced:**
    - Implement your own lock service by extending the aspect or LockService interface
    - Customize lock behavior by overriding `LockAspect`

Performance &amp; Best Practices
--------------------------------

[](#performance--best-practices)

- Only use locking where necessary, as it introduces network overhead
- Keep lock scope as small as possible
- Use fine-grained keys to maximize concurrency
- Ensure all nodes have synchronized clocks in distributed setups
- Monitor for lock timeouts and failures

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

[](#contributing)

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

Issues and PRs are welcome!

- Follow PSR coding standards
- Add tests for new features
- Run static analysis: `composer phpstan`

License
-------

[](#license)

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

Changelog
---------

[](#changelog)

See [Releases](https://packagist.org/packages/tourze/symfony-aop-lock-bundle#releases) for version history.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance74

Regular maintenance activity

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

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 ~63 days

Total

5

Last Release

144d ago

Major Versions

0.0.3 → 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 (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/tourze-symfony-aop-lock-bundle/health.svg)](https://phpackages.com/packages/tourze-symfony-aop-lock-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)[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)[sulu/sulu

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

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

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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