friendsofhyperf/command-signals

The signals component for Hyperf Command.

Maintainers

πŸ‘ huangdijia

Package info

github.com/friendsofhyperf/command-signals

Issues

Documentation

pkg:composer/friendsofhyperf/command-signals

Fund package maintenance!

huangdijia

hdj.me/sponsors

Statistics

Installs: 37 089

Dependents: 5

Suggesters: 0

Stars: 1

v3.2.1 2026-06-09 14:51 UTC

Requires

Requires (Dev)

None

Suggests

Provides

None

Conflicts

None

Replaces

None

MIT aa984b6a20ac85aa0bc51d2ca6cc1870613cc34d

  • huangdijia <huangdijia.woop@gmail.com>

hyperfv3.2


README

δΈ­ζ–‡θ―΄ζ˜Ž

πŸ‘ Latest Stable Version
πŸ‘ Total Downloads
πŸ‘ License

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

Contact

License

MIT