承接 joshdifabio/future-process 相关项目开发

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

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

joshdifabio/future-process

最新稳定版本:v0.2.0

Composer 安装命令:

composer require joshdifabio/future-process

包简介

Process execution for PHP using futures and promises

README 文档

README

Build Status Codecov Code Quality

Introduction

Future Process is object-oriented proc_open with an asynchronous API and automatic queueing of commands.

Usage

// we use Shell to start new processes
$shell = new \FutureProcess\Shell;

// run a maximum of 5 concurrent processes - additional ones will be queued
$shell->setProcessLimit(5);

// let's download this package's license file from GitHub using wget
$url = 'https://raw.githubusercontent.com/joshdifabio/future-process/master/LICENSE';
$process = $shell->startProcess("wget -O - $url");

Non-blocking

We can consume the process output using promises.

// this will not block, even if the process is queued
$process->then(function ($process) {
    echo "Downloading file...\n";
});

// this will not block, even if the process is queued
$process->getResult()->then(function ($result) {
    echo "File contents:\n{$result->readFromPipe(1)}\n";
});

// this will block until all processes have exited
$shell->wait();

Blocking

We can also consume the process output synchronously.

// this will block until the process starts
$process->wait();
echo "Downloading file...\n";

// this will block until the process exits
echo "File contents:\n{$process->getResult()->readFromPipe(1)}\n";

Installation

Install Future Process using composer.

composer require joshdifabio/future-process

License

Future Process is released under the MIT license.

统计信息

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

GitHub 信息

  • Stars: 25
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-05