phasty/process 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

phasty/process

Composer 安装命令:

composer require phasty/process

包简介

PHP for asynchronous task execution

README 文档

README

Allows you make any job in another php-process with ability to get feedback from child process during all execution time:

// Child process code:
use Phasty\process\Child\CallableClass;
class ChildProcess extends CallableClass {
    public $property = "A";
    public function doAsyncJob($arg1, $arg2) {
        $this->trigger("doneJob", (object)[ "result" => $arg1 . $arg2  . $this->property ]);
    }
}

And parent process code:

use Phasty\Stream\StreamSet;
use Phasty\Process\Child\Controller;

$process = new Controller(ChildProcess::getClass());
/*
  or you can use instance of class ChildProcess with predefined state like this:
  $childJob = new ChildProcess;
  $childJob->property = "B";
  $process = new Controller($childJob);
 */

$process->on("start", function () {
    echo "Child process started\n";
});

$process->on("stop", function () {
    echo "Child process stopped\n";
});

$process->on("doneJob", function ($event) {
    echo "Got result from child: " . $event->getData()->result . "\n";
});

$process->doAsyncJob("foo", "bar");

StreamSet::instance()->listen();
echo "stopped\n";

After execution you should see:

Child process started
Got result from child: foobarA
Child process stopped
stopped

You can receive event "error" in parent process on child object in case of catchable error occured or signal (including SIGTERM, SIGFAULT etc)

Coming soon:

1. Killing process with $process->kill();

2. Getting result code

  1. Bi-directional link (sending commands to child)

4. Getting stop reason (normal, signals like segmentation fault and so on)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-07-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固