PHPackages                             mmeyer2k/semlock - 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. mmeyer2k/semlock

ActiveLibrary

mmeyer2k/semlock
================

semaphores + closures

1.0.1(3y ago)2462.6k↑154.3%MITPHPPHP ^7.0|^8.0

Since Apr 1Pushed 3y agoCompare

[ Source](https://github.com/mmeyer2k/semlock)[ Packagist](https://packagist.org/packages/mmeyer2k/semlock)[ RSS](/packages/mmeyer2k-semlock/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (4)Used By (0)

💎semlock
========

[](#gemsemlock)

A clean way to wrap semaphores around closures to perform exclusive execution of code. Semlock also allows for naming semaphones with descriptive strings instead of ints.

Read my blog posting about this tool here:

Install
-------

[](#install)

`composer require mmeyer2k/semlock`

Use
---

[](#use)

### Basic Usage

[](#basic-usage)

```
\mmeyer2k\SemLock::synchronize('some_key', function () {
    $x = get_number_from_database();

    $x++;

    sleep(5);

    save_number_to_database($x);
});
```

### Handling return values

[](#handling-return-values)

The `semlock` library will pass return values from the closure back to the calling context.

```
$returned = \mmeyer2k\SemLock::synchronize('some_key', function () {
    return 'something';
});

# $returned === 'something'
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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

Every ~1149 days

Total

2

Last Release

1455d ago

PHP version history (2 changes)1.0.0PHP ^7.0

1.0.1PHP ^7.0|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c39fe5f8d80dda8a5735401c12cb631d5e17050f7baa7cd3f0f384167fb45db?d=identicon)[mmeyer2k](/maintainers/mmeyer2k)

---

Top Contributors

[![mmeyer2k](https://avatars.githubusercontent.com/u/1887431?v=4)](https://github.com/mmeyer2k "mmeyer2k (7 commits)")

---

Tags

closurephpsemaphore

### Embed Badge

![Health badge](/badges/mmeyer2k-semlock/health.svg)

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

PHPackages © 2026

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