1. Go to this page and download the library: Download seld/signal-handler library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
seld / signal-handler example snippets
use Seld\Signal\SignalHandler;
$signal = SignalHandler::create();
while (true) {
// do some work here ...
// exit gracefully at the end of an iteration if the process interruption was called for
if ($signal->isTriggered()) {
$signal->exitWithLastSignal();
}
}
use Seld\Signal\SignalHandler;
$signal = SignalHandler::create();
try {
// do things
} finally {
$signal->unregister();
}
use Seld\Signal\SignalHandler;
// using strings for the constant names makes sure the code will run on Windows and
// OSX even if the signal is missing on those platforms
$signal = SignalHandler::create([SignalHandler::SIGHUP, SignalHandler::SIGUSR1]);
while (true) {
// do some work here ...
// reload the config when the signal was triggered
if ($signal->isTriggered()) {
$this->reloadConfiguration();
// reset the handler so next time you check isTriggered() it
// will be false, until SIGHUP/SIGUSR1 is signaled again
$signal->reset();
}
}
use Seld\Signal\SignalHandler;
$signal = SignalHandler::create(null, new PSR3Logger());
use Seld\Signal\SignalHandler;
$signal = SignalHandler::create([SignalHandler::SIGINT], function (string $signalName, SignalHandler $self) {
echo 'Received ' . $signalName . PHP_EOL;
// you can optionally receive the SignalHandler instance as second arg to do things on it like
// resetting its state or exiting to handle the signal
$self->reset();
$self->exitWithLastSignal();
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.