承接 innmind/signals 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

innmind/signals

Composer 安装命令:

composer require innmind/signals

包简介

Manage multiple callbacks per signal

README 文档

README

CI codecov Type Coverage

Small abstraction on top of pcntl_signal to allow to register multiple callables for a single signal.

Installation

composer require innmind/signals

Usage

use Innmind\Signals\{
    Handler,
    Signal,
    Info,
};

$handler = Handler::main(); // automatically enable async signal on first `->listen()` call

$handler
    ->listen(Signal::interrupt, function(Signal $signal, Info $info): void {
        echo 'foo';
    })
    ->unwrap();
$handler
    ->listen(Signal::interrupt, function(Signal $signal, Info $info): void {
        echo 'bar';
    })
    ->unwrap();

// do some logic here

When above script is executed in a terminal and you do a ctrl + c to stop the process it will print foobar instead of stopping the script.

If for some reason you need to remove a handler (for example when a child process ended) you can call $handler->remove($listener)->unwrap() (remove the listener for all signals).

统计信息

  • 总下载量: 102.58k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固