PHPackages                             net\_bazzline/component\_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. net\_bazzline/component\_lock

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

net\_bazzline/component\_lock
=============================

php component lock

2.3.0(9y ago)01.6k1[1 PRs](https://github.com/stevleibelt/php_component_lock/pulls)2LGPLv3PHPPHP ^5.6||^7.0

Since Jul 1Pushed 5y ago1 watchersCompare

[ Source](https://github.com/stevleibelt/php_component_lock)[ Packagist](https://packagist.org/packages/net_bazzline/component_lock)[ Docs](https://github.com/stevleibelt/php_component_lock)[ RSS](/packages/net-bazzline-component-lock/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (11)Used By (2)

Process Lock Component
======================

[](#process-lock-component)

The build status of the current master branch is tracked by Travis CI: [![Build Status](https://camo.githubusercontent.com/0f9aa8616c6681170eb64419a0bd5d3aec4b60f79fb24846fd883a07499fc88f/68747470733a2f2f7472617669732d63692e6f72672f737465766c656962656c742f7068705f636f6d706f6e656e745f6c6f636b2e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/stevleibelt/php_component_lock)

[![Latest stable](https://camo.githubusercontent.com/38ac3f67be32f3c9cfb240abb125c0011fed7252da1d74d2849222b62867ff1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e65745f62617a7a6c696e652f636f6d706f6e656e745f6c6f636b2e737667)](https://packagist.org/packages/net_bazzline/component_lock)

The scrutinizer status is: [![code quality](https://camo.githubusercontent.com/a9d99f4a48d42686a1651c69062153ea446ec69603a17838ce76ffd464590569/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f737465766c656962656c742f7068705f636f6d706f6e656e745f6c6f636b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/stevleibelt/php_component_lock/)

The versioneye status is: [![Dependency Status](https://camo.githubusercontent.com/1362291dc306cd6f5c4066ae4260c1130315f2c4b732ebe6b3cbede2619e2c54/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3537373363386135393965643239303034396238623964612f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/5773c8a599ed290049b8b9da)

Minimum PHP version is: [![Minimum PHP Version](https://camo.githubusercontent.com/86e7d829a466cacd5658a22073e27d49d39dac72cc18216ac4963ed5463c5bbc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e362d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://php.net/)

Take a look on [openhub.net](https://www.openhub.net/p/php_component_lock).

General
=======

[](#general)

This component provides the *LockInterface* as well as an *LockAwareInterface*. It comes with two implementations of the LockInterface.

You can use this interface to lock classes or processes to prevent changes in an object (so you freeze/lock the class for property setting) or lock an existing process (like a cronjob) to prevent double execution.

This component was created by splitting up the [PHP\_Bazzline\_Utility](https://github.com/stevleibelt/archive/tree/master/php/bazzlineUtility) repository.

Implementations
===============

[](#implementations)

Two implementations exists. The *FileNameLock* and the *RuntimeLock*.

RuntimeLock
-----------

[](#runtimelock)

The RuntimeLock can be used to lock an instance from modification. If you implement an check in each setter method, you can easily create a instance (by a factory for example) and lock it afterwards to prevent modifications.

FileNameLock
------------

[](#filenamelock)

The FileNameLock can be used to lock an class from instantiated multiple times. This is useful if you implement this in cronjobs or business processes that should run alone.

FileHandlerLock
---------------

[](#filehandlerlock)

The FileHandlerLock can be used to lock file with php`s [flock](https://secure.php.net/manual/en/function.flock.php) functionality.

Future Improvements
===================

[](#future-improvements)

- implement "wait" like implemented [here](https://github.com/thecodingmachine/utils.common.lock/blob/master/src/LockInterface.php).
- take a look to the [semaphore](https://github.com/zerkalica/Semaphore) project to see if thing can be merged
- take a look if all projects can work together
- take a look to [havvg/lock](https://github.com/havvg/Lock)

History
=======

[](#history)

- upcomming
    - @todo
- [2.3.0](https://github.com/stevleibelt/php_component_lock/tree/2.3.0) - released 2017-01-26
    - updated minimum requirements to php 5.6
- [2.2.1](https://github.com/stevleibelt/php_component_lock/tree/2.2.1) - released 2016-06-29
    - added integrationtest for php 7.0
    - added links to:
        - latest stable build
        - scrutinizer code quality
        - versioneye dependency status
    - migrated to psr-4 autoloading
    - removed integrationtest for php 5.3.3
- [2.2.0](https://github.com/stevleibelt/php_component_lock/tree/2.2.0) - released 2016-06-28
    - added phpunit 5.4 as dependency (if php version is fitting)
    - added process id into the lock file as requested as [feature](https://github.com/stevleibelt/php_component_lock/issues/1)
    - updated dependencies
- [2.1.0](https://github.com/stevleibelt/php_component_lock/tree/2.1.0) - released 2015-09-10
    - implemented support for *SplFileObject* in *FileHandlerLock*
- [2.0.1](https://github.com/stevleibelt/php_component_lock/tree/2.0.1) - released 2015-09-09
    - stabalized dependencies
- [2.0.0](https://github.com/stevleibelt/php_component_lock/tree/2.0.0) - released 2015-09-08
    - added *FileHandlerLock*
    - renamed *FileLock* to *FileNameLock*
    - renamed "getName" to "getResource" and "setName" to "setResource" in "LockInterface"
- [1.0.3](https://github.com/stevleibelt/php_component_lock/tree/1.0.3)
    - added LockDependentInterface
- [1.0.2](https://github.com/stevleibelt/php_component_lock/tree/1.0.2)
    - added constructor with optional parameter $name for *FileNameLock* and *RuntimeLock*
- [1.0.1](https://github.com/stevleibelt/php_component_lock/tree/1.0.1)
    - switched to LGPLv3
- [1.0.0](https://github.com/stevleibelt/php_component_lock/tree/v1.0.0)
    - added implementation for *FileLock* and *RuntimeLock*
    - covered implementations with unittest
    - finished *LockInterface* and *LockAwareInterface*

Final Words
===========

[](#final-words)

Star it if you like it :-). Add issues if you need it. Pull patches if you enjoy it. Write a blog entry if you use it. [Donate something](https://gratipay.com/~stevleibelt) if you love it :-\].

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity64

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

Recently: every ~126 days

Total

10

Last Release

3391d ago

Major Versions

1.0.3 → 2.0.02015-09-08

PHP version history (2 changes)v1.0.0PHP &gt;=5.3.3

2.3.0PHP ^5.6||^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/58451b041f6f5a38c7e62762c96d01f5e2bcac30e322707fe4760a82bccb6856?d=identicon)[artodeto](/maintainers/artodeto)

---

Top Contributors

[![stevleibelt](https://avatars.githubusercontent.com/u/2287220?v=4)](https://github.com/stevleibelt "stevleibelt (50 commits)")

---

Tags

phpcomponentlocknet\_bazzline

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/net-bazzline-component-lock/health.svg)

```
[![Health](https://phpackages.com/badges/net-bazzline-component-lock/health.svg)](https://phpackages.com/packages/net-bazzline-component-lock)
```

###  Alternatives

[phpoffice/common

PHPOffice Common

23512.3M36](/packages/phpoffice-common)[tomatophp/filament-icons

Picker &amp; Table Column &amp; Icons Provider for FilamentPHP

3598.2k13](/packages/tomatophp-filament-icons)

PHPackages © 2026

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