werkint / react-pcntl
This package is abandoned and no longer maintained.
The author suggests using the werkint/react-pcntl package instead.
PCNTL bindings for ReactPHP
v2.1.0
2016-05-12 19:46 UTC
Requires
- php: >=5.4
- ext-pcntl: *
- evenement/evenement: 2.0.*
- react/event-loop: 0.4.*
Requires (Dev)
- satooshi/php-coveralls: ^1.0
This package is not auto-updated.
Last update: 2022-02-01 13:02:59 UTC
README
Basic PCNTL bindings for React PHP.
##Install
The best way to install this library is through composer:
{ "require": { "mkraemer/react-pcntl": "2.1.*" } }
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();