eonx-com / easy-lock
Framework agnostic locking features
Requires
- php: ^8.2
- psr/log: ^3.0
- symfony/config: ^7.2
- symfony/dependency-injection: ^7.2
- symfony/http-kernel: ^7.2
- symfony/lock: ^7.2
- symfony/messenger: ^7.2
- symfony/service-contracts: ^3.5
Requires (Dev)
- doctrine/collections: ^1.7.2 || ^2.1
- doctrine/dbal: ^3.8
- doctrine/doctrine-bundle: ^2.12
- doctrine/orm: ^2.20
- laravel/lumen-framework: ^11.0
- phpunit/phpunit: ^10.5.63|^11.5.50|^12.5.8
Suggests
- eonx-com/easy-async: For EasyAsync integration
- eonx-com/easy-logging: For Laravel and EasyLogging integration
- symfony/messenger: For Symfony Messenger integration
This package is auto-updated.
Last update: 2026-08-18 15:59:54 UTC
README
---eonx_docs--- title: Introduction weight: 0 ---eonx_docs---
The purpose of this package isn't to be used within a project by the application as there is no point in creating another level of abstraction in that case BUT only to allow eonx-com packages to dispatch events without having to think about the event dispatcher used by each of our projects.
Require package (Composer)
The recommended way to install this package is to use Composer:
$ composer require eonx-com/easy-lock
Usage
The Symfony Lock component has an excellent documentation and we recommend referring to it.
Connection
To work with this package you simply have to register the connection to use for the locks store as a service under
the easy_lock.connection id. This connection will be given to the StoreFactory, so its value can be anything
supported by the Lock component.
Store
If defining the connection doesn't work for you, you can override the store instance within the service container under
the easy_lock.store id.
Lock factory
The package registers a Symfony\Component\Lock\LockFactory built on its own store and logger under the
easy_lock.lock_factory id, so there is no need to create your own instance of the lock factory. Wire it explicitly
where you need it:
use Symfony\Component\Lock\LockFactory; final readonly class MyService { public function __construct( private LockFactory $lockFactory, ) { } public function doSomething(): void { $lock = $this->lockFactory->createLock('my-resource'); // ... } }
// config/services.php $services->set(MyService::class) ->arg('$lockFactory', service('easy_lock.lock_factory'));
The same lock factory instance is used by EonX\EasyLock\Common\Locker\LockerInterface internally.
Nothing is registered under the Symfony\Component\Lock\LockFactory class name on purpose. FrameworkBundle claims
that name as soon as framework.lock is enabled, which is the default once symfony/lock is installed, and its
default factory uses a flock store that does not lock across application instances. A plain LockFactory
type-hint therefore resolves to whatever the application configured, which is why the wiring above is explicit.