PHPackages                             unreal4u/pid - 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. unreal4u/pid

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

unreal4u/pid
============

This class is a wrapper for OS and PID files

v2.0.6(11y ago)319.8k1[3 issues](https://github.com/unreal4u/pid/issues)[1 PRs](https://github.com/unreal4u/pid/pulls)MITPHPPHP &gt;=5.3.0

Since Dec 27Pushed 2y agoCompare

[ Source](https://github.com/unreal4u/pid)[ Packagist](https://packagist.org/packages/unreal4u/pid)[ RSS](/packages/unreal4u-pid/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/4721a8af37c70e809c4babf41e720ea2cfc430cb74bc777ba90db695fd9577ef/68747470733a2f2f706f7365722e707567782e6f72672f756e7265616c34752f7069642f762f737461626c652e706e67)](https://packagist.org/packages/unreal4u/pid)[![Build Status](https://camo.githubusercontent.com/0062e26ae3d4a71ac9a45bb0d905ff00841da2c5767a6ee180055de0f1f164a3/68747470733a2f2f7472617669732d63692e6f72672f756e7265616c34752f7069642e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/unreal4u/pid)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c22568b0e32f36e479c3d936f5720f5fbfa2bff27a2eedc5fc20050200273fd2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f756e7265616c34752f7069642f6261646765732f7175616c6974792d73636f72652e706e673f733d32353036313735353062383330383434333734633833306539353564666264643331646633633131)](https://scrutinizer-ci.com/g/unreal4u/pid/)[![Code Coverage](https://camo.githubusercontent.com/a00767807d5896abd12586425a9af4242167ed12e952bacbcd7e1fd13b3ab438/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f756e7265616c34752f7069642f6261646765732f636f7665726167652e706e673f733d36396635386666336433303635363562636465373063303435383738343230663762626462643239)](https://scrutinizer-ci.com/g/unreal4u/pid/)[![License](https://camo.githubusercontent.com/75c8c0a56ab823c422f817a635ce853948413c511f1be643f723024c765421bf/68747470733a2f2f706f7365722e707567782e6f72672f756e7265616c34752f7069642f6c6963656e73652e706e67)](https://packagist.org/packages/unreal4u/pid)

pid.php
=======

[](#pidphp)

Credits
-------

[](#credits)

This class is made by unreal4u (Camilo Sperberg). [unreal4u.com/](http://unreal4u.com).

About this class
----------------

[](#about-this-class)

- Can be used to verify whether a process is already running or not.
- Is platform independant: Can be used in Windows or Linux. In both, they will call OS specific functions to find out whether the process is running or not.
- It does not detect previous fatal errors, but it can omit the previous PID file if a given time has passed since the creation.

Detailed description
--------------------

[](#detailed-description)

This package will check if a certain PID file is present or not, and depending on that will:

Create a PID file. If it already exists, will ask the OS to check whether it is still a running process. If for whatever reason, the OS still thinks the process is still running and too much time has passed, the class can overwrite the previous PID file (Thus initiating a new instance). When the object is destroyed, the corresponding PID file will be deleted as well.

Basic usage
-----------

[](#basic-usage)

```
include('src/unreal4u/pid.php');
try {
    $pid = new unreal4u\pid();
} catch (\Exception $e) {
    echo $e->getMessage();
}

if ($pid->isAlreadyRunning) {
    echo 'Your process is already running';
}
```

- `$pid->pid` will show you the pid number.
- **Please see examples for more options and advanced usage**
- There is only one caveat: if you are going to use this class inside a method within a class, ensure that the destructor gets executed when it should: variables are immediatly destroyed after the method finishes executing, so the PID will be destroyed as well. To ensure this, assign the PID class to an object inside the class, that way, whenever that object gets destroyed, this class will be as well.

Composer
--------

[](#composer)

This class has support for (preferably) Composer install. Just add the following section to your composer.json with:

```
{
    "require": {
        "unreal4u/pid": "@stable"
    }
}
```

Now you can instantiate a new pid class by executing:

```
require('vendor/autoload.php');

try {
    $pid = new unreal4u\pid();
} catch (\Exception $e) {
    // Do something
}
```

Pending
-------

[](#pending)

- Better (more thorough) code coverage on PHPUnit tests.
- Test this class thoroughly on a windows machine, many UNIX improvements has been made in the meantime.

Version History
---------------

[](#version-history)

- 1.0 :
    - Initial version
- 1.1:
    - Support for Windows PID check
- 1.3:
    - PHPUnit testing
    - Documentation improved (Created this README actually)
    - More examples
- 1.3.1:
    - Script now set itself a maximum execution time
- 1.4.0:
    - Class is now compatible with composer
- 1.4.2:
    - Better documentation
    - Better code coverage
- 1.4.5:
    - Travis-CI support
    - Began deprecating old coding standard
- 2.0.0:
    - Mayor rewrite of basic functioning of the class
    - Variables can now be passed on as an array instead of per variable
    - Class now throws (more) exceptions when something went wrong
    - More tests regarding new functionality
    - Backwards compatibility changes:
        - Class will now throw exceptions when it fails at some part instead of silently failing
        - Function `getTSpidFile()` renamed to `getTimestampPidFile()`

Contact the author
------------------

[](#contact-the-author)

- Twitter: [@unreal4u](http://twitter.com/unreal4u)
- Website:
- Github:
- Packagist: \[\]

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

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

Recently: every ~71 days

Total

16

Last Release

4061d ago

Major Versions

v1.4.6 → v2.0.0-beta12014-04-17

PHP version history (2 changes)v1.4.0PHP &gt;=5.1.6

v1.4.3PHP &gt;=5.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/43792f8b224d7de339a848cd799635fa8e062eea3fb669e3ca7a1d1e2cff756d?d=identicon)[unreal4u](/maintainers/unreal4u)

---

Top Contributors

[![unreal4u](https://avatars.githubusercontent.com/u/194999?v=4)](https://github.com/unreal4u "unreal4u (55 commits)")[![mcorten](https://avatars.githubusercontent.com/u/1099530?v=4)](https://github.com/mcorten "mcorten (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/unreal4u-pid/health.svg)

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

###  Alternatives

[knplabs/knp-components

Knplabs component library

77343.6M46](/packages/knplabs-knp-components)[bangnokia/laravel-serve-livereload

Bring livereload to laravel artisan serve command

1008.9k](/packages/bangnokia-laravel-serve-livereload)[markbaker/phpgeodetic

Geodetic library

2013.0k](/packages/markbaker-phpgeodetic)[justintadlock/hybrid-carbon

God-like post featured image script.

202.5k](/packages/justintadlock-hybrid-carbon)

PHPackages © 2026

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