PHP code example of friendsofhyperf / command-signals
1. Go to this page and download the library: Download friendsofhyperf/command-signals 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/ */
friendsofhyperf / command-signals example snippets
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!');
}
}
shell
$ hyperf foo
Received signal 15, exiting...
[1] 51936 terminated php bin/hyperf.php foo
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.