roadrunner-php/symfony-lock-driver

RoadRunner: symfony/lock bridge

Maintainers

Package info

github.com/roadrunner-php/symfony-lock-driver

Homepage

Issues

Chat

Forum

Documentation

pkg:composer/roadrunner-php/symfony-lock-driver

Transparency log

Fund package maintenance!

roadrunner-server

Statistics

Installs: 21 679

Dependents: 1

Suggesters: 1

Stars: 1

1.1.2 2026-07-20 09:05 UTC

This package is auto-updated.

Last update: 2026-07-20 09:06:27 UTC


README

RoadRunner Lock Integration for Symfony

PHP Version Require Latest Stable Version phpunit psalm Codecov Total Downloads

This package is a bridge that connects the powerful RoadRunner Lock plugin with the Symfony Lock component. It's designed to help you easily manage distributed locks in your PHP applications, particularly when you're working with high-traffic web applications and microservices.

Requirements

Make sure that your server is configured with following PHP version and extensions:

  • PHP 8.1+

Installation

You can install the package via composer:

composer require roadrunner-php/symfony-lock-driver

Usage

Using the RoadRunner Lock with Symfony is straightforward. Here's a simple example:

use RoadRunner\Lock\Lock;
use Spiral\Goridge\RPC\RPC;
use Spiral\RoadRunner\Symfony\Lock\RoadRunnerStore;
use Symfony\Component\Lock\LockFactory;

require __DIR__ . '/vendor/autoload.php';

$lock = new Lock(RPC::create('tcp://127.0.0.1:6001'));
$factory = new LockFactory(
    new RoadRunnerStore($lock)
);

Store options

RoadRunnerStore accepts two timing options:

Option Default Description
$initialTtl 300.0 Default lock time-to-live, in seconds. When it elapses the lock is released automatically; 0 means it never expires on its own.
$initialWaitTtl 0 Default time to wait for the lock to become free, in seconds. 0 is effectively non-blocking: the RoadRunner server caps a 0 wait at 1ms, so acquiring an already-held lock fails almost immediately. A positive value blocks for up to that duration.
// Wait up to 5 seconds for the lock, and hold it for at most 30 seconds.
$store = (new RoadRunnerStore($lock))->withTtl(ttl: 30.0, waitTtl: 5.0);

Read more about using Symfony Lock component here.

Contributing

Contributions are welcome! If you find an issue or have a feature request, please open an issue or submit a pull request.

Credits

License

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