friendsofhyperf / command-signals
The signals component for Hyperf Command.
                                    Fund package maintenance!
                                                                            
                                                                                                                                        huangdijia
                                                                                    
                                                                            
                                                                                                                                        hdj.me/sponsors
                                                                                    
                                                                
Installs: 17 795
Dependents: 8
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
pkg:composer/friendsofhyperf/command-signals
Requires
- hyperf/context: ~3.2.0
 - hyperf/engine: ^2.0
 - hyperf/support: ~3.2.0
 
Suggests
- ext-swoole: >=4.6.0
 - ext-swow: >=0.1.0
 
- 3.2.x-dev
 - v3.2.0-alpha.1
 - dev-main / 3.1.x-dev
 - v3.1.69
 - v3.1.58
 - v3.1.57
 - v3.1.48
 - v3.1.41
 - v3.1.31
 - v3.1.28.1
 - v3.1.27
 - v3.1.17
 - v3.1.15
 - v3.1.14.1
 - v3.1.14
 - v3.1.1
 - v3.1.0
 - v3.1.0-rc.4
 - v3.1.0-beta.20
 - v3.1.0-beta.15
 - v3.1.0-beta.9
 - v3.1.0-beta.3
 - v3.1.0-beta.1
 - 3.0.x-dev
 - v3.0.119.1
 - v3.0.119
 - v3.0.85
 - v3.0.80
 - v3.0.70
 - v3.0.60
 - v3.0.55
 - v3.0.52
 - v3.0.51
 - v3.0.49
 - v3.0.44
 - v3.0.42
 - v3.0.35
 - v3.0.14
 - v3.0.2
 - v3.0.0
 - v3.0.0-rc.16
 - v3.0.0-rc.9
 - v3.0.0-rc.8
 
This package is auto-updated.
Last update: 2025-11-02 01:56:54 UTC
README
The signals component for Hyperf Command.
Installation
composer require friendsofhyperf/command-signals
Usage
namespace App\Command; use FriendsOfHyperf\CommandSignals\Traits\InteractsWithSignals; use Hyperf\Command\Annotation\Command; use Hyperf\Command\Command as HyperfCommand; use Psr\Container\ContainerInterface; #[Command] class FooCommand extends HyperfCommand { use InteractsWithSignals; public function __construct(protected ContainerInterface $container) { parent::__construct('foo'); } public function configure() { parent::configure(); $this->setDescription('Hyperf Demo Command'); } public function handle() { $this->trap([SIGINT, SIGTERM], function ($signo) { $this->warn(sprintf('Received signal %d, exiting...', $signo)); }); sleep(10); $this->info('Bye!'); } }
Run
Ctrl + C
$ hyperf foo ^CReceived signal 2, exiting...
killall php
$ hyperf foo Received signal 15, exiting... [1] 51936 terminated php bin/hyperf.php foo