PHPackages                             eclipxe/php-soft-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. eclipxe/php-soft-daemon

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

eclipxe/php-soft-daemon
=======================

PHP Library to wait for system signals and running code

v3.0.0(1mo ago)0431MITPHPPHP &gt;=8.2CI passing

Since Aug 21Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/eclipxe13/php-soft-daemon)[ Packagist](https://packagist.org/packages/eclipxe/php-soft-daemon)[ Docs](https://github.com/eclipxe13/php-soft-daemon)[ RSS](/packages/eclipxe-php-soft-daemon/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (6)Used By (0)

eclipxe/php-soft-daemon
=======================

[](#eclipxephp-soft-daemon)

[![Source Code](https://camo.githubusercontent.com/a514957d5afc355487032cd585aa7e904848258768c351d17b86258c379987ab/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d65636c697078652f7068702d2d736f66742d2d6461656d6f6e2d626c75653f7374796c653d666c61742d737175617265)](https://github.com/eclipxe13/php-soft-daemon)[![Packagist PHP Version Support](https://camo.githubusercontent.com/faca420b8c7365b58b9009958100ac3fb1a71b9eb3417c47892df410afa30760/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f65636c697078652f7068702d736f66742d6461656d6f6e3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/eclipxe13/php-soft-daemon)[![Latest Version](https://camo.githubusercontent.com/192c851c2bf036da5873e064ff1b115533f0dc6e01bfebba7702064a407a4211/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f65636c6970786531332f7068702d736f66742d6461656d6f6e3f7374796c653d666c61742d737175617265)](https://github.com/eclipxe13/php-soft-daemon/releases)[![Software License](https://camo.githubusercontent.com/d6b685bd273c813eb1b0407b4adc1ce6ea7dd5ef1c11d8698aa2eb85a8a19bce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f65636c6970786531332f7068702d736f66742d6461656d6f6e3f7374796c653d666c61742d737175617265)](https://github.com/eclipxe13/php-soft-daemon/blob/main/LICENSE)[![Build Status](https://camo.githubusercontent.com/aa794c87ad16f0091bd47245d1eae027dc7e07fc200efd1cdea49af134c9c8ae/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f65636c6970786531332f7068702d736f66742d6461656d6f6e2f6275696c642e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/eclipxe13/php-soft-daemon/actions/workflows/build.yml?query=branch:main)[![Scrutinizer](https://camo.githubusercontent.com/aeeae55983440502a481d9369efcbfaa1188183f5d2513b7375e824bc90d63a9/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f65636c6970786531332f7068702d736f66742d6461656d6f6e2f6d61696e3f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/eclipxe13/php-soft-daemon/)[![Coverage Status](https://camo.githubusercontent.com/4eb657ffddfdbe6534b8fed073c776e02505e42c9cc6e5471c3058658670cfc0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f65636c6970786531332f7068702d736f66742d6461656d6f6e2f6d61696e3f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/eclipxe13/php-soft-daemon/code-structure/main/code-coverage)[![Total Downloads](https://camo.githubusercontent.com/748ed5c489d18bf09dd68304ca1a271c9126e769477762073513000b8976b681/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f65636c697078652f7068702d736f66742d6461656d6f6e3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/eclipxe/php-soft-daemon)

PHP SoftDaemon Library
----------------------

[](#php-softdaemon-library)

SoftDaemon provides a library to run continuously some code.

I create this library to execute procedures continuously and to manipulate the time between iterations. I also use it to send signals to the processes in order to manipulate the behavior of the execution.

Do not reinvent the wheel, if cron jobs are suitable to you then use them.

How it runs
-----------

[](#how-it-runs)

You have to create an instance of `SoftDaemon`, it requires minimum an `Executable` object that implements `SoftDaemon\Executable` interface.

The `SoftDaemon\Executable` interface requires that you create two methods:

- Will call `signalHandler(int $signo): void` to optionally do something with the signal.
- Will call `runOnce(): bool` on each iteration.

For example, you can use `signalHandler($signo)` to process `SIGHUP`.

Once you have instantiated a `SoftDaemon` object you can call the method `run()`. This method will enter into a loop and run `Executable::runOnce()` on every iteration. At the end on every iteration the loop will wait.

### Signals used

[](#signals-used)

These signals are catched by SoftDaemon. All signals pass to `Executable::signalHandler($signo)` before `SoftDaemon` do its own processing.

- *SIGHUP*: Reset the error counter to zero. Method: `SoftDaemon::resetErrorCounter()`.
- *SIGUSR1*: Pause iterations. Method: `SoftDaemon::setPause(true)`.
- *SIGUSR2*: Unpause iterations. Method: `SoftDaemon::setPause(false)`.
- *SIGTERM*, *SIGINT*, *SIGQUIT*: Terminate the iterations. Method: `SoftDaemon::terminate()`.

How SoftDaemon knows how many seconds will wait
-----------------------------------------------

[](#how-softdaemon-knows-how-many-seconds-will-wait)

The pause state determines the quantity of seconds to wait for signals and continue to the next iteration.

If the SoftDaemon is **on pause** then it will not call `runOnce`, it will only try to wait 1 second.

If **not on pause** then it will use the counter of errors and request the sequencer to determine the number of seconds to wait.

The result of `Executable::runOnce(): bool` determines the number of errors. It is reset to zero when `runOnce()` returns `true`. It is increased by 1 when `runOnce()` returns `false`.

Anyhow, the number of seconds will be bounded to `minWait` and `maxWait` properties.

About sequencers
----------------

[](#about-sequencers)

A sequencer is an object that implements `SoftDaemon\Sequencer`. Its purpose is to receive the number of errors and return a quantity of seconds to wait. There are some predefined *Sequencers* already defined in the namespace `SoftDaemon\Sequencers`:

- *Fixed*: It always returns the same quantity of seconds.
- *Linear*: It returns the quantity of seconds as the count of errors `(0 -> 0, 1 -> 1, 2 -> 2, ...)`.
- *Exponential*: It returns the quantity of seconds as the count of errors to an exponential minus 1, if the base is 2 then it will return the following numbers: `(0 -> 0, 1 -> 1, 2 -> 3, 3 -> 7, 4 -> 15, ...)`.

You can create a sequencer with your own rules. The `minWait` and `maxWait` limit the boundaries of seconds returned by the sequencer.

PHP Support
-----------

[](#php-support)

This library is compatible with at least the oldest [PHP Supported Version](http://php.net/supported-versions.php)with **active** support. Please, try to use PHP full potential.

We adhere to [Semantic Versioning](https://semver.org/). We will not introduce any compatibility backwards change on major versions.

Internal classes (using `@internal` annotation) are not part of this agreement as they must only exist inside this project. Do not use them in your project.

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

[](#contributing)

Contributions are welcome! Please read [CONTRIBUTING](https://github.com/eclipxe13/php-soft-daemon/blob/main/CONTRIBUTING.md) for details and don't forget to take a look the [TODO](https://github.com/eclipxe13/php-soft-daemon/blob/main/docs/TODO.md) and [CHANGELOG](https://github.com/eclipxe13/php-soft-daemon/blob/main/docs/CHANGELOG.md) files.

Copyright and License
---------------------

[](#copyright-and-license)

The `eclipxe/php-soft-daemon` library is copyright © [Carlos C Soto](http://eclipxe.com.mx/)and licensed for use under the MIT License (MIT). Please see [LICENSE](https://github.com/eclipxe13/php-soft-daemon/blob/main/LICENSE) for more information.

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance91

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity79

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

Total

4

Last Release

44d ago

Major Versions

v1.0.0 → v2.0.02021-07-29

v2.0.1 → v3.0.02026-04-04

PHP version history (3 changes)v1.0.0PHP &gt;=5.4

v2.0.0PHP &gt;=7.3

v3.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/66964609?v=4)[eclipxe](/maintainers/eclipxe)[@Eclipxe](https://github.com/Eclipxe)

---

Top Contributors

[![eclipxe13](https://avatars.githubusercontent.com/u/1266852?v=4)](https://github.com/eclipxe13 "eclipxe13 (68 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/eclipxe-php-soft-daemon/health.svg)

```
[![Health](https://phpackages.com/badges/eclipxe-php-soft-daemon/health.svg)](https://phpackages.com/packages/eclipxe-php-soft-daemon)
```

###  Alternatives

[ezsystems/ezpublish-legacy-installer

Installer for eZ Publish legacy extensions and legacy kernel itself.

10466.7k200](/packages/ezsystems-ezpublish-legacy-installer)

PHPackages © 2026

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