mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 03:26:22 +00:00
873 B
873 B
date | id | title |
---|---|---|
2020-11-17 | 1aeeea82-1193-447d-95ae-4196175d6721 | Console Signals |
Description
Symfony supports console signals1.
Syntax
// ...
use Symfony\Component\Console\Command\SignalableCommandInterface;
class SignalCommand extends Command implements SignalableCommandInterface
{
// ...
protected function execute(InputInterface $input, OutputInterface $output): int
{
// ...
}
public function getSubscribedSignals(): array
{
// return here any of the constants defined by PCNTL extension
// https://www.php.net/manual/en/pcntl.constants.php
return [SIGINT, SIGTERM];
}
public function handleSignal(int $signal)
{
if (SIGINT === $signal) {
// ...
}
// ...
}
}