PHPackages                             ncrypthic/daemon - 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. [CLI &amp; Console](/categories/cli)
4. /
5. ncrypthic/daemon

ActiveLibrary[CLI &amp; Console](/categories/cli)

ncrypthic/daemon
================

1.0.0(12y ago)2491[1 issues](https://github.com/ncrypthic/daemon/issues)MITPHP

Since Dec 23Pushed 10y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (3)Used By (0)

Background
----------

[](#background)

We often need to implement a long running script in background to do house keeping tasks for our application.

There are couple of techniques that we can use as listed bellow :

1. With cron by default there are no process control mechanism. If we set a script to run every minute, then it is very that there will be a race condition between process execution when every process of script takes more time than the scheduled time to finish.
2. When we use one script to execute a collection of tasks in an array using loop. The tasks will be executed one after another. This will make the last task in the collection have to wait for earlier tasks to finish.

What this library do
--------------------

[](#what-this-library-do)

This library provides basic threaded process control to run our tasks but we want to prevent race condition by running each tasks in order on forked child process using PHP **pcntl** extension.

Minimum Requirements
--------------------

[](#minimum-requirements)

1. **PHP &gt;= 5.3.6**
2. Installed and enabled **pcntl extension**

Installing
----------

[](#installing)

- Via composer

```
requires: {
    "ncrypthic/daemon": "dev-master"
}

```

Running
-------

[](#running)

- Create process(es) classes which implements **ProcessInterface** interface

```
