amphp/process
Composer 安装命令:
composer require amphp/process
包简介
A fiber-aware process manager based on Amp and Revolt.
README 文档
README
AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind.
amphp/process provides an asynchronous process dispatcher that works on all major platforms (including Windows).
It makes running child processes simple.
As Windows pipes are file handles and do not allow non-blocking access, this package makes use of a process wrapper, that provides access to these pipes via sockets. On Unix-like systems it uses the standard pipes, as these can be accessed without blocking there. Concurrency is managed by the Revolt event loop.
Installation
This package can be installed as a Composer dependency.
composer require amphp/process
The package requires PHP 8.1 or later.
Usage
Processes are started with Process::start():
<?php require __DIR__ . "/vendor/autoload.php"; use Amp\ByteStream; use Amp\Process\Process; // "echo" is a shell internal command on Windows and doesn't work. $command = DIRECTORY_SEPARATOR === "\\" ? "cmd /c echo Hello World!" : "echo 'Hello, world!'"; $process = Process::start($command); Amp\async(fn () => Amp\ByteStream\pipe($process->getStdout(), ByteStream\getStdout())); Amp\async(fn () => Amp\ByteStream\pipe($process->getStderr(), ByteStream\getStderr())); $exitCode = $process->join(); echo "Process exited with {$exitCode}.\n";
Custom Working Directory
Processes are started with the working directory of the current process by default. The working directory can be customized to another directory if needed:
$process = Amp\Process\Process::start($command, workingDirectory: '/path/of/your/dreams');
Custom Environment Variables
Processes are started with the environment variables of the current process by default. The environment can be customized by passing an associative array mapping variables names to their values:
$process = Amp\Process\Process::start($command, environment: [ 'PATH' => '/usr/bin/local' ]);
Versioning
amphp/process follows the semver semantic versioning specification like all other amphp packages.
Security
If you discover any security related issues, please use the private security issue reporter instead of using the public issue tracker.
License
The MIT License (MIT). Please see LICENSE for more information.
amphp/process 适用场景与选型建议
amphp/process 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 60.18M 次下载、GitHub Stars 达 256, 最近一次更新时间为 2015 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 amphp/process 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 amphp/process 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 60.18M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 258
- 点击次数: 41
- 依赖项目数: 62
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-22