PHPackages                             acet/reslock - 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. acet/reslock

ActiveLibrary

acet/reslock
============

Dependable advisory resource lock - for files and other contentious resources

1.0.0(5y ago)046GPL-3.0PHPPHP ^5.3.3 || ^7.0

Since Jun 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/andy-ce-taylor/reslock)[ Packagist](https://packagist.org/packages/acet/reslock)[ RSS](/packages/acet-reslock/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

ResLock
=======

[](#reslock)

#### Advisory resource lock for files and other resources (similar to flock but works on all platforms).

[](#advisory-resource-lock-for-files-and-other-resources-similar-to-flock-but-works-on-all-platforms)

Mainly used to protect a file from being written-to by two or more processes at the same time. This is similar to the PHP flock() function, the differences being that this is dependable (even on Windows) and that the lock applies to any resource - not just files.

It works by checking for the absence/presence of a directory to determine whether an exclusive lock has been achieved. A directory is used in preference to a file because the mkdir() function will, in a single platform-independent operation, return whether or not a directory exists and create it if it doesn't.

On Windows systems, at least, this method is more reliable than standard flock() which requires two operating system operations - check whether the lock-file exists, and create it if it doesn't. Since there are 2 operations, it is possible for several processes to be checking at the same time; each one concluding that the lock-file doesn't exist, each one creating the file, and each one believing it has an exclusive lock.

\####Requirements ResLock requires the following:

- PHP 5.3.3+

\####Installation ResLock is installed via Composer. To add a dependency to ResLock in your project, either

Run the following to use the latest stable version

```
composer require acet/reslock

```

or if you want the latest master version

```
composer require acet/reslock:dev-master

```

You can also manually edit your composer.json file

{ "require": { "acet/reslock": "v0.1.\*" } }

\####Example - Update a file which may have other interested parties

```
use acet\ResLock;

$contentious_file = 'contentious.file';

$reslock = new ResLock();

// Provide a name for the resource (any string will do - can be a file name, or the name of your cat)
if ($reslock->lock('tiddles')) {

    // resource successfully locked

    $file_contents = file_get_contents($contentious_file);
    $string = "Do something";
    file_put_contents($contentious_file, $string);

    $reslock->unlock();
}

else {
    throw new exception("Unable to lock the resource");
}

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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

Total

3

Last Release

2143d ago

Major Versions

0.0.1 → 1.0.02020-07-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/594ca862fcb2e5b8b89038fac79a05bf72d5aa5dd756bbfa84ade3c9fd9b55c1?d=identicon)[andy-ce-taylor](/maintainers/andy-ce-taylor)

---

Tags

phprace conditionflocklockresource-lockfile lockadvisory lock

### Embed Badge

![Health badge](/badges/acet-reslock/health.svg)

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

###  Alternatives

[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)[yriveiro/php-fslock

A simple lock implementation using flock.

18101.8k](/packages/yriveiro-php-fslock)[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)
