PHPackages                             yriveiro/php-fslock - 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. yriveiro/php-fslock

ActiveLibrary

yriveiro/php-fslock
===================

A simple lock implementation using flock.

3.0.1(6y ago)18101.8k↓81.3%1MITPHPPHP &gt;=7.0.0CI failing

Since Sep 29Pushed 6y ago1 watchersCompare

[ Source](https://github.com/yriveiro/php-fslock)[ Packagist](https://packagist.org/packages/yriveiro/php-fslock)[ RSS](/packages/yriveiro-php-fslock/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (3)Versions (7)Used By (0)

FSLock
======

[](#fslock)

[![Build Status](https://camo.githubusercontent.com/27e2de6147aea7c6666294e71f69a7682439a2ca971510150bec64169a2cb0a7/68747470733a2f2f7472617669732d63692e6f72672f797269766569726f2f7068702d66736c6f636b2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/yriveiro/php-fslock)[![Coverage Status](https://camo.githubusercontent.com/6a9e1583eabd86ca420ffe3530b1b55f572c8cc1ac9065cfd5dc1c60d2db3366/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f797269766569726f2f7068702d66736c6f636b2f62616467652e706e67)](https://coveralls.io/r/yriveiro/php-fslock)[![Total Downloads](https://camo.githubusercontent.com/dc7a7ce99af99dbdc1ac359a282c24d08258fa1ce8f8e5fa974218519e7cb88a/68747470733a2f2f706f7365722e707567782e6f72672f797269766569726f2f7068702d66736c6f636b2f646f776e6c6f6164732e737667)](https://packagist.org/packages/yriveiro/php-fslock)

A simple lock implementation using flock.

*NOTE:* to use php-backoff with PHP 5.x please use the lastet release of branch 2.x

Usage
=====

[](#usage)

```
use FSLock\FSLock;

$lock = new FSLock('test');

if ($lock->acquire()) {
    // Critical code.

    $lock->release();
}
```

If you want to use a custom path to store the locks, you should instantiate the FSLock like that

```
$lock = new FSLock('test', '/tmp/');
```

API
===

[](#api)

- `acquire`: Acquires the lock, returns *true* if the operation was successful otherwise the return is *false*.
- `release`: Releases the lock, returns *true* if the operation was successful otherwise the return is *false*.
- `id`: returns the lock id.
- `getPath`: returns the lock path

Install
=======

[](#install)

The recommended way to install this package is through [Composer](http://getcomposer.org/download/).

```
composer require yriveiro/php-fslock:3.0.0
```

Tests
=====

[](#tests)

Tests are performed using the `phpunit` library, to run them:

```
php vendor/bin/phpunit tests
```

License
=======

[](#license)

FSLock is licensed under MIT license.

###  Health Score

36

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 98.2% 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 ~572 days

Total

5

Last Release

2267d ago

Major Versions

0.1 → 2.0.02016-01-31

2.x-dev → 3.0.02018-10-01

PHP version history (2 changes)0.1PHP &gt;=5.3.3

3.0.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7554ea3632f73106aa0ea29305bdb42cac32406edf0d8bdf651c703c19603986?d=identicon)[yriveiro](/maintainers/yriveiro)

---

Top Contributors

[![yriveiro](https://avatars.githubusercontent.com/u/934763?v=4)](https://github.com/yriveiro "yriveiro (54 commits)")[![tatenen](https://avatars.githubusercontent.com/u/3715976?v=4)](https://github.com/tatenen "tatenen (1 commits)")

---

Tags

filesystem-locklockphpphpflocklocklock file

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/yriveiro-php-fslock/health.svg)

```
[![Health](https://phpackages.com/badges/yriveiro-php-fslock/health.svg)](https://phpackages.com/packages/yriveiro-php-fslock)
```

###  Alternatives

[malkusch/lock

Mutex library for exclusive code execution.

9659.4M26](/packages/malkusch-lock)[arvenil/ninja-mutex

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

1983.6M24](/packages/arvenil-ninja-mutex)[avtonom/semaphore-bundle

A generic locking Symfony bundle for PHP, that uses named locks for semaphore acquire and release, to guarantee atomicity

122.8k](/packages/avtonom-semaphore-bundle)

PHPackages © 2026

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