PHPackages                             swordev/mutex - 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. swordev/mutex

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

swordev/mutex
=============

Read-write concurrency control

0.1.0(6y ago)13MITPHP

Since Jul 27Pushed 6y agoCompare

[ Source](https://github.com/swordev/mutex-php)[ Packagist](https://packagist.org/packages/swordev/mutex)[ Docs](https://github.com/swordev/mutex-php)[ RSS](/packages/swordev-mutex/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Mutex
=====

[](#mutex)

> Read-write concurrency control

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

[](#installation)

```
composer require @swordev/mutex
```

Usage
-----

[](#usage)

### File read/write lock

[](#file-readwrite-lock)

```
use Swordev\Mutex\FileMutex;

$mutex1 = new FileMutex('key');
$mutex2 = new FileMutex('key');

$mutex1->readLock(); // true
$mutex2->writeLock(); // false

$mutex1->unlock(); // true
$mutex2->writeLock(); // true
```

### Timeout

[](#timeout)

```
use Swordev\Mutex\FileMutex;

$mutex = new FileMutex('key');
$mutex->writeLock(5000);
```

### Contextual lock

[](#contextual-lock)

```
use Swordev\Mutex\FileMutex;

class Foo {
	function method() {
		$mutex = new FileMutex(__CLASS__ . '|' . __FUNCTION__);
		$mutex->writeLock();
		// ...
	}
}
```

### Mutex factory

[](#mutex-factory)

```
use Swordev\Mutex\MutexFactory;

$mutex = new MutexFactory::create(FileMutex::class, 'key');
```

Development
-----------

[](#development)

### Test

[](#test)

```
composer run test
```

### Analyse

[](#analyse)

```
composer run analyse
```

Author
------

[](#author)

Juanra GM -

Distributed under the MIT license.

###  Health Score

21

—

LowBetter than 17% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

2212d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25853205?v=4)[swordev](/maintainers/swordev)[@swordev](https://github.com/swordev)

---

Top Contributors

[![juanrgm](https://avatars.githubusercontent.com/u/54169354?v=4)](https://github.com/juanrgm "juanrgm (3 commits)")

---

Tags

concurrencysemaphoremutexflocklock

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/swordev-mutex/health.svg)

```
[![Health](https://phpackages.com/badges/swordev-mutex/health.svg)](https://phpackages.com/packages/swordev-mutex)
```

###  Alternatives

[symfony/lock

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

515143.4M785](/packages/symfony-lock)[malkusch/lock

Mutex library for exclusive code execution.

94910.3M31](/packages/malkusch-lock)[yriveiro/php-fslock

A simple lock implementation using flock.

18102.7k](/packages/yriveiro-php-fslock)[kitpages/semaphore-bundle

This is a Symfony2 bundle that provides a semaphore system.

107.4k1](/packages/kitpages-semaphore-bundle)

PHPackages © 2026

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