PHPackages                             yusitnikov/php-elock-client - 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. yusitnikov/php-elock-client

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yusitnikov/php-elock-client
===========================

Simple eLock client on PHP

1.2.1(1y ago)090MITPHP

Since Jul 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/yusitnikov/php-elock-client)[ Packagist](https://packagist.org/packages/yusitnikov/php-elock-client)[ RSS](/packages/yusitnikov-php-elock-client/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

PHP eLock Client
================

[](#php-elock-client)

Simple eLock client on PHP. Also supports features of NodeJS eLock server.

What is eLock?
--------------

[](#what-is-elock)

eLock is a simple distributed lock server on erlang.

Advantages:

- fault-tolerant
- simple to install and to use
- safe from race conditions - all operations are atomic
- all locks required by a client are being unlocked automatically when the client disconnects

See [source repository](https://github.com/dustin/elock).

What is NodeJS eLock server?
----------------------------

[](#what-is-nodejs-elock-server)

NodeJS eLock server is an implementation of original eLock protocol on NodeJS with an addition of deadlock detection.

Advantages:

- all advantages of original eLock protocol
- when lock attempt causes a recursive lock circle, a deadlock is automatically reported with 423 response code
- supports value locks
- has "debug" command

See [source repository](https://github.com/yusitnikov/node-elock-server).

Install eLock server
--------------------

[](#install-elock-server)

### Original eLock server

[](#original-elock-server)

1. [Install erlang OTP](https://hostpresto.com/community/tutorials/how-to-install-erlang-on-ubuntu-16-04/)
2. [Install and run eLock server](http://dustin.sallings.org/elock/admin.html)

### NodeJS eLock server

[](#nodejs-elock-server)

1. [Install NodeJS/npm](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions)
2. [Install and run eLock server](https://github.com/yusitnikov/node-elock-server#install)

It would be listening on port 11400.

Install eLock client
--------------------

[](#install-elock-client)

The client is available as a composer dependency:

```
composer install yusitnikov/php-elock-client
```

Use eLock client
----------------

[](#use-elock-client)

### Basic usage

[](#basic-usage)

```
$key1 = 'unique-resource-key1';
$key1 = 'unique-resource-key2';
$lockTimeout = 5;

// Create a client of an original eLock server
$client = new ELockClient('your.elock.server.host.or.ip');
// or create a client of a NodeJS eLock server
$client = new ELockClientEx('your.elock.server.host.or.ip');

// Tell to release all locks after the disconnection
$client->setTimeout(0);

// Lock keys
$lockedKey1 = $client->lock($key1, $lockTimeout);
$lockedKey2 = $client->lock($key2, $lockTimeout);

// Unlock key
$unlockedKey1 = $client->unlock($key1);

// Unlock all keys you own
$client->unlockAll();

// Disconnect from the server
$client->quit();
$client->close();
```

### Common usage for atomic operations

[](#common-usage-for-atomic-operations)

```
// Lock the resource with a timeout that's big enough to wait for other clients to finish their job
if (!$client->lock($key, $timeout)) {
    throw new Exception('Failed to lock the resource XXX during YYY seconds');
}

try {
    // Do something with the locked resource
} finally {
    // Ensure that the resource will be unlocked in the case of unexpected error
    $client->unlock($key);
}
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~433 days

Recently: every ~541 days

Total

6

Last Release

727d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13732463?v=4)[Yuri Sitnikov](/maintainers/yusitnikov)[@yusitnikov](https://github.com/yusitnikov)

---

Top Contributors

[![ysitnikov](https://avatars.githubusercontent.com/u/13730673?v=4)](https://github.com/ysitnikov "ysitnikov (6 commits)")[![muli](https://avatars.githubusercontent.com/u/1042806?v=4)](https://github.com/muli "muli (1 commits)")[![yusitnikov](https://avatars.githubusercontent.com/u/13732463?v=4)](https://github.com/yusitnikov "yusitnikov (1 commits)")

### Embed Badge

![Health badge](/badges/yusitnikov-php-elock-client/health.svg)

```
[![Health](https://phpackages.com/badges/yusitnikov-php-elock-client/health.svg)](https://phpackages.com/packages/yusitnikov-php-elock-client)
```

###  Alternatives

[symfony/lock

Creates and manages locks, a mechanism to provide exclusive access to a shared resource

514135.1M626](/packages/symfony-lock)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[phpro/soap-client

A general purpose SoapClient library

8895.9M52](/packages/phpro-soap-client)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k42](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751284.3k37](/packages/civicrm-civicrm-core)[illuminate/broadcasting

The Illuminate Broadcasting package.

7126.9M203](/packages/illuminate-broadcasting)

PHPackages © 2026

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