PHP code example of alexeyshockov / symfony-signal-helper
1. Go to this page and download the library: Download alexeyshockov/symfony-signal-helper 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/ */
alexeyshockov / symfony-signal-helper example snippets
#!/usr/bin/env php
// ...
$console = new Application();
$console->getHelperSet()->set(new SignalHelper());
$console->run($input);
protected function execute(InputInterface $input, OutputInterface $output)
{
$helper = $this->getHelper('signal');
$helper->listen();
while (true) {
if (count(array_intersect([SIGINT, SIGTERM], $helper->takeSignals())) > 0) {
// Stop by any of SIGINT or SIGTERM.
break;
}
// Some business logic.
}
}