mkraemer/react-pcntl

PCNTL bindings for ReactPHP

Maintainers

πŸ‘ mkraemer

Package info

github.com/mkraemer/react-pcntl

pkg:composer/mkraemer/react-pcntl

Statistics

Installs: 290 633

Dependents: 14

Suggesters: 1

Stars: 57

Open Issues: 0

v3.0.0 2017-07-24 19:56 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 39d6af793c3a61edbde70c130b2b7dca9f316789

  • Marius KrΓ€mer <marius.woop@marius-kraemer.de>

reactpcntl

This package is not auto-updated.

Last update: 2026-06-20 22:35:15 UTC


README

Since v0.5 of ReactPHP event-loop offers native support for signal handling.

React-PCNTL

πŸ‘ Build Status
πŸ‘ Coverage Status

Basic PCNTL bindings for React PHP.

Install

The best way to install this library is through composer:

{
 "require": {
 "mkraemer/react-pcntl": "^3.0.*"
 }
}

This library depends on the PCNTL extension. Note: version 2 of this library requires PHP >= 5.4. If you are using PHP 5.3, use the 1.0.* version:

{
 "require": {
 "mkraemer/react-pcntl": "1.0.*"
 }
}

Usage

This library provides the PCNTL class which taskes an event loop and optionally the timer interval in which the PCNTL signals should be read as constructor arguments. After initializing the class, you can use the on() method to register event listeners to PCNTL signals.

$loop = React\EventLoop\Factory::create();
$pcntl = new MKraemer\ReactPCNTL\PCNTL($loop);

$pcntl->on(SIGTERM, function () {
 // Clear some queue
 // Write syslog
 // Do ALL the stuff
 echo 'Bye'.PHP_EOL;
 die();
});

$pcntl->on(SIGINT, function () {
 echo 'Terminated by console'.PHP_EOL;
 die();
});

echo 'Started as PID '.getmypid().PHP_EOL;
$loop->run();