eonx-com/easy-lock

Framework agnostic locking features

Maintainers

Package info

github.com/eonx-com/easy-lock

pkg:composer/eonx-com/easy-lock

Transparency log

Statistics

Installs: 1 183 159

Dependents: 5

Suggesters: 0

Stars: 1

Open Issues: 1

6.22.5 2026-06-05 16:28 UTC

This package is auto-updated.

Last update: 2026-07-14 08:11:43 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 Symfony\Component\Lock\LockFactory as a service, configured with the package's store and logger, so there is no need to create your own instance of the lock factory. You can simply inject it into your services:

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');

        // ...
    }
}

The same lock factory instance is used by EonX\EasyLock\Common\Locker\LockerInterface internally.