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

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

leocavalcante/swoole-mutex
==========================

Mutual exclusion abstractions for PHP's Swoole concurrency run-time.

821PHPCI failing

Since Apr 11Pushed 6y ago1 watchersCompare

[ Source](https://github.com/leocavalcante/swoole-mutex)[ Packagist](https://packagist.org/packages/leocavalcante/swoole-mutex)[ RSS](/packages/leocavalcante-swoole-mutex/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Mutex
=====

[](#mutex)

[![Actions Status](https://github.com/leocavalcante/swoole-mutex/workflows/CI/badge.svg)](https://github.com/leocavalcante/swoole-mutex/actions)

🚦 [Mutual exclusion](https://en.wikipedia.org/wiki/Mutual_exclusion) abstractions for PHP's [Swoole](https://www.swoole.co.uk/) concurrency run-time.

> With great power comes great responsibility — Uncle Ben (I guess)

[Swoole](https://www.swoole.co.uk/) awesomeness enables concurrency across multiple processes and cores, but sharing state/memory between them isn't a straightforward achievement. [`Swoole\Table`](https://www.swoole.co.uk/docs/modules/swoole-table) comes to help, but maybe we could have an even better API for that task.

**This package is a [Facade](https://en.wikipedia.org/wiki/Facade_pattern) for [`Swoole\Table`](https://www.swoole.co.uk/docs/modules/swoole-table) providing common APIs for mutual exclusion patterns.**

*We all hail [**Edsger W. Dijkstra**](https://en.wikipedia.org/wiki/Edsger_W._Dijkstra) (and [Swoole team](https://github.com/orgs/swoole/people) for their amazing work).*

Install
-------

[](#install)

```
composer require leocavalcante/swoole-mutex
```

Example
-------

[](#example)

Counting HTTP requests across &gt;1 workers.

```
use Mutex\Atomic\Integer;
use Swoole\Http\{Request, Response, Server};

$counter = new Integer();
$server = new Server('127.0.0.1', 8000);

$server->on('request', function (Request $req, Response $res) use ($counter): void {
    if ($req->server['request_uri'] !== '/favicon.ico') {
        $counter->inc();
    }

    $res->end('You are number: ' . $counter->value());
});

$server->set(['worker_num' => 4]);
$server->start();
```

---

© 2k2O

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/940717934113da7abe00589e87cfde6f34496f039bcd3fc6ce4a33f5f415d4ac?d=identicon)[leocavalcante](/maintainers/leocavalcante)

---

Top Contributors

[![leocavalcante](https://avatars.githubusercontent.com/u/183722?v=4)](https://github.com/leocavalcante "leocavalcante (22 commits)")

---

Tags

concurrencymutexphpswoole

### Embed Badge

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

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

###  Alternatives

[webpatser/laravel-uuid

Laravel integration for webpatser/uuid - High-performance drop-in UUID replacements (15% faster than Ramsey). Provides Str macros, HasUuids trait, facades, and casts. RFC 4122/9562 compliant.

1.8k17.3M129](/packages/webpatser-laravel-uuid)

PHPackages © 2026

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