ReactPHP Child Process

Event-driven library for spawning and controlling child processes with ReactPHP, exposing STDIN, STDOUT, and STDERR as non-blocking streams.

Library
Composer
vv0.6.7
343stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
43/100Fair
Development Activity0
Maintenance20
Community72
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture84
Code Quality82
Innovation72
Learning Curve70

ReactPHP Child Process integrates PHP’s program execution facilities with the ReactPHP event loop, letting you launch external commands without blocking your application. Each spawned process exposes its standard I/O pipes as readable and writable streams and emits an exit event on termination, so you can pipe data, react to output incrementally, and manage many concurrent processes from a single-threaded, event-driven PHP application.

What You Get

  • A Process class that launches any shell command against the ReactPHP event loop
  • Non-blocking STDIN, STDOUT, and STDERR exposed as ReactPHP stream interfaces
  • An exit event carrying the exit code and terminating signal for each process
  • Support for custom pipes, signalling, and process termination

Common Use Cases

  • Streaming output from long-running CLI commands as it is produced
  • Running many external processes concurrently in a single PHP worker
  • Building async task runners, build tools, or job workers on top of ReactPHP

Under The Hood

Architecture

The library centers on the React\ChildProcess\Process class, which wraps PHP’s proc_open and binds the resulting pipes to the ReactPHP event loop. On start(), it constructs React\Stream readable and writable stream instances for STDIN, STDOUT, and STDERR, registers the process with the loop, and polls for termination to emit the exit event with exit code and signal.

Tech Stack

Pure PHP (7.1+ and 8.x) with no runtime extensions required for the default stream-select loop. It depends on react/event-loop and react/stream, and optionally leverages ext-libevent, ext-libev, or ext-event loops when installed. Distributed via Composer as react/child-process.

Code Quality

The codebase is small and focused, with a comprehensive PHPUnit suite in tests/ covering multiple event-loop backends (stream-select, libev, libevent, ext-event). Naming follows ReactPHP conventions, error paths surface through events, and the project maintains separate 0.6.x and 0.7 development branches with a documented changelog.

API Design

The public surface is deliberately minimal: construct a Process, call start(), and attach listeners to well-named events. The stream-based design composes naturally with the rest of the ReactPHP ecosystem, so developers already using ReactPHP need almost no new concepts to adopt it.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search