PHPackages                             f3ath/flock - 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. f3ath/flock

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

f3ath/flock
===========

Simple locking mechanism on top of flock()

1.0.1(8y ago)1345[1 PRs](https://github.com/f3ath/flock/pulls)MITPHPPHP &gt;=5.6

Since Feb 25Pushed 8y agoCompare

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

READMEChangelog (4)Dependencies (3)Versions (9)Used By (0)

[![Travis Build](https://camo.githubusercontent.com/b69d4cf4074db6f87d31b77befd80a0b5b253285e2cb771bd8b7efd34e1b460a/68747470733a2f2f7472617669732d63692e6f72672f66336174682f666c6f636b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/f3ath/flock)

Flock. Simple locking mechanism on top of flock()
=================================================

[](#flock-simple-locking-mechanism-on-top-of-flock)

Usage
-----

[](#usage)

```
$file = '/tmp/my_lock.pid';
$lock = new F3\Flock\Lock($file);

// Non-blocking case. Acquire lock if it's free, otherwse exit immediately
if ($lock->acquire()) {
    // only one instance can reach here
    ...
    // do some job
    ...
    $lock->release();
} else {
    die('Another process is running')
}

// Waiting case. Acquire lock if it's free, otherwse block until it's free and then acquire
if ($lock->acquire(F3\Flock\Lock::BLOCKING)) {
    // only one instance can reach here
    ...
    // do some job
    ...
    $lock->release();
} else {
    // We sould not get to this point in this case
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity63

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

Recently: every ~325 days

Total

7

Last Release

3140d ago

Major Versions

0.0.3 → 1.0.0-alpha02017-01-09

PHP version history (2 changes)0.0.1PHP &gt;=5.3.0

1.0.0-alpha0PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/f342ce8504c834a3ac4fcf17b31c1e750cd4dc6f24be523d28ce2b96609a7582?d=identicon)[f3ath](/maintainers/f3ath)

---

Top Contributors

[![f3ath](https://avatars.githubusercontent.com/u/831399?v=4)](https://github.com/f3ath "f3ath (17 commits)")

---

Tags

cronlockingflocklock

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/f3ath-flock/health.svg)

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

###  Alternatives

[dragonmantank/cron-expression

CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due

4.7k474.1M482](/packages/dragonmantank-cron-expression)[symfony/lock

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

514127.6M457](/packages/symfony-lock)[malkusch/lock

Mutex library for exclusive code execution.

9459.6M27](/packages/malkusch-lock)[arvenil/ninja-mutex

Simple to use mutex implementation that can use flock, memcache, memcached, mysql or redis for locking

1873.7M27](/packages/arvenil-ninja-mutex)[symfony/scheduler

Provides scheduling through Symfony Messenger

8810.8M52](/packages/symfony-scheduler)[pudongping/hyperf-wise-locksmith

A mutex library provider for the Hyperf framework, designed to enable serialized execution of PHP code in high-concurrency scenarios.

106.3k2](/packages/pudongping-hyperf-wise-locksmith)

PHPackages © 2026

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