PHPackages                             hollyit/laravel-lock - 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. hollyit/laravel-lock

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

hollyit/laravel-lock
====================

A Laravel wrapper for the Symfony Lock component to provide semaphore style locks on long running processes.

v0.1.0(6y ago)31.7kMITPHPPHP ^7.1.3

Since Aug 28Pushed 6y ago1 watchersCompare

[ Source](https://github.com/HollyIT/laravel-lock)[ Packagist](https://packagist.org/packages/hollyit/laravel-lock)[ Docs](https://github.com/hollyit/laravel-lock)[ RSS](/packages/hollyit-laravel-lock/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (4)Used By (0)

Laravel Lock
============

[](#laravel-lock)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bad91ccb3837d39c05396c97871ecc1c31389ba24fed195826e2fe3260a5a818/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686f6c6c7969742f6c61726176656c2d6c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hollyit/laravel-lock)[![Build Status](https://camo.githubusercontent.com/41dc816902ee1c60d68fda5e908675e81e3545b27a8db6fd04181afca4e37c0e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f686f6c6c7969742f6c61726176656c2d6c6f636b2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/hollyit/laravel-lock)

\##Description

A simple Laravel wrapper for the [Symfony lock](https://symfony.com/doc/current/components/lock.html) component to provide semaphore locking.

Why?
----

[](#why)

When you have routines that take a longer time than usual to run, you may not want other processes attempting to run it. To prevent this you can acquire what is referred to as a lock or semaphore. This prevents problems of [contention](https://en.wikipedia.org/wiki/Resource_contention).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require hollyit/laravel-lock
```

Usage
-----

[](#usage)

```
$lock = LaravelLock::make('test-lock')
if ($lock->acquire()) {
  // Perform my long running task
  $lock->release();
} else {
  // Something is already running on this process so let's not do anything.
}
```

### Currently supported drivers

[](#currently-supported-drivers)

Drivers can be configured in config/lock.php. View that file for additional details. To publish the configuration

```
php artisan vendor:publish --provider="Hollyit\LaravelLock\LaravelLockServiceProvider" --tag="config"
```

**File Drive:**

*(This is a wrapper of the [Symfony FlockStore](https://symfony.com/doc/current/components/lock.html#flockstore))*

No additional setup required. By default this will use the system's temporary directory. You may override this in config or environment. Please see config/lock.php for details.

With the exception of Database, drivers are very simple wrappers. If you would like to add additional drivers, please consider a PR.

**Database driver:**

*(This is a modification of the [PdoStore](https://symfony.com/doc/current/components/lock.html#lock-store-pdo), modified to use Laravel's database layer)*

This will use your default database connection. Before using this driver you must publish and migrate your database.

```
php artisan vendor:publish --provider="Hollyit\LaravelLock\LaravelLockServiceProvider" --tag="migraions"
```

If you wish to use a custom table name, then please modify your config/lock.php file prior to migrating.

**Redis:**

Redis isn't currently supported, but it will in a future release.

**Custom drivers:**

Other [stores](https://symfony.com/doc/current/components/lock.html#available-stores) from the Symfony/lock package aren't currently supported. Migrating them over should be rather simple if you would like to (and please submit a PR).

You may also define custom drivers outside of what the original symfony/lock package offers. Under your config/lock.php configuration file, simple define a 'class' property to point to the class of the new driver. Drivers must implement the \\Hollyit\\LaravelLock\\Contracts\\LockDriver contract.

### Additional details

[](#additional-details)

For additional details and features, please refer to the Symfony Lock [documentation](https://symfony.com/doc/current/components/lock.html).

### Testing

[](#testing)

***NOTE**: Testing is extremely limited at this time given the need for this package on a client project. If you are willing to expand on test coverage, please do so and submit a PR.*

```
composer test
```

Contributing
------------

[](#contributing)

This package was quickly developed due to the need of a current client project. If you would like to add more drivers, features or tests, then your help will be greatly welcomed.

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Jamie Holly](https://github.com/hollyit)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

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

Total

2

Last Release

2442d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/58617d67178941252c10067cd88583a4f1773569b630372930c6412fbc939979?d=identicon)[HollyIT](/maintainers/HollyIT)

---

Top Contributors

[![HollyIT](https://avatars.githubusercontent.com/u/527984?v=4)](https://github.com/HollyIT "HollyIT (8 commits)")

---

Tags

symfonylaravelsemaphorelockingflockhollyitlaravel-lock

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hollyit-laravel-lock/health.svg)

```
[![Health](https://phpackages.com/badges/hollyit-laravel-lock/health.svg)](https://phpackages.com/packages/hollyit-laravel-lock)
```

###  Alternatives

[symfony/lock

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

514127.6M459](/packages/symfony-lock)[brexis/laravel-workflow

Integerate Symfony Workflow component into Laravel.

283125.6k](/packages/brexis-laravel-workflow)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)

PHPackages © 2026

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