PHPackages                             zerkalica/semaphore - 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. zerkalica/semaphore

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

zerkalica/semaphore
===================

This library provides an api for semaphore acquire and release

v1.1.1(8y ago)1119.0k7[1 PRs](https://github.com/zerkalica/Semaphore/pulls)1MITPHP

Since Apr 15Pushed 4y ago1 watchersCompare

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

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

Millwright semaphore library
============================

[](#millwright-semaphore-library)

This library provides an api for semaphore acquire and release.

Support adapters: flock, pdo, doctrine/orm, apc, memcached, sem

Usage:

```
$adapter   = new \Millwright\Semaphore\Adapter\ApcAdapter;
$semaphore = new \Millwright\Semaphore\Model\SemaphoreManager($adapter);

$ttl = 60; // Time in seconds, used, if script dies and release never called.

$handle = $semaphore->acquire('lock key', $ttl);

// Do something thread-safe

$semaphore->release($handle);
```

SQL table schema:

```
CREATE TABLE `semaphore__semaphore` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `expire_date` datetime NOT NULL,
  `semaphore_key` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `semaphore_key_idx` (`semaphore_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
```

Example model for doctrine adapter. Doctrine adapter works directrly with sql-table. This model only creates appropriate table.

```
/**
 * Semaphore entity
 *
 * @ORM\Entity()
 *
 * @ORM\Table(name="semaphore__semaphore",
 *     uniqueConstraints={@ORM\UniqueConstraint(name="semaphore_key_idx", columns={"semaphore_key"})}
 * )
 */
class Semaphore
{
    /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(name="expire_date", type="datetime", nullable=false)
     */
    protected $date;

    /**
     * @ORM\Column(name="semaphore_key", type="string", nullable=false)
     */
    protected $key;
}
```

###  Health Score

37

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~395 days

Total

3

Last Release

3251d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/06052ad7decfcf0505d3e9bd0d7c51eeb95317020bc52e71551941aa8fabe99a?d=identicon)[zerkalica](/maintainers/zerkalica)

---

Top Contributors

[![zerkalica](https://avatars.githubusercontent.com/u/274786?v=4)](https://github.com/zerkalica "zerkalica (6 commits)")[![pedromazala](https://avatars.githubusercontent.com/u/2103162?v=4)](https://github.com/pedromazala "pedromazala (5 commits)")[![HadesArchitect](https://avatars.githubusercontent.com/u/1742301?v=4)](https://github.com/HadesArchitect "HadesArchitect (3 commits)")[![ioborin](https://avatars.githubusercontent.com/u/18030928?v=4)](https://github.com/ioborin "ioborin (2 commits)")[![4ernovm](https://avatars.githubusercontent.com/u/1623891?v=4)](https://github.com/4ernovm "4ernovm (1 commits)")[![webcraft](https://avatars.githubusercontent.com/u/56675?v=4)](https://github.com/webcraft "webcraft (1 commits)")

---

Tags

semaphoreutillock

### Embed Badge

![Health badge](/badges/zerkalica-semaphore/health.svg)

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

###  Alternatives

[symfony/lock

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

514127.6M455](/packages/symfony-lock)[symfony/semaphore

Symfony Semaphore Component

373.9M6](/packages/symfony-semaphore)[jansenfelipe/utils

Uma simples classe utilitária com métodos que podem salvar sua vida (ou não)

62146.4k10](/packages/jansenfelipe-utils)[codeliner/array-reader

PHP ArrayReader

19276.1k9](/packages/codeliner-array-reader)[kevinlebrun/slug.php

Slug helpers

4451.4k1](/packages/kevinlebrun-slugphp)[kevinlebrun/password.php

Helpers for password generation and validation

17142.3k1](/packages/kevinlebrun-passwordphp)

PHPackages © 2026

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