swiekenb/pcntl

PCNTL进程控制库

v7.1.0 2024-08-03 13:17 UTC

This package is auto-updated.

Last update: 2024-09-03 17:45:09 UTC


README

基于默认PCNTL和POSIX函数的简单易用的PHP线程化进程管理器。

Build status

更多信息

安装

composer require "sweikenb/pcntl"

基本用法

use Sweikenb\Library\Pcntl\ProcessManager;
use Sweikenb\Library\Pcntl\Api\ChildProcessInterface;
use Sweikenb\Library\Pcntl\Api\ParentProcessInterface;
use Sweikenb\Library\Pcntl\Api\ProcessOutputInterface;

$pm = new ProcessManager();
$pm->runProcess(function(ChildProcessInterface $child, ParentProcessInterface $parent, ProcessOutputInterface $output) {
    $output->stdout(sprintf('Hello World from PID: %d', $child->getId()));
});