Fast Forward Fork
fast-forward/fork
is a PHP 8.3+ library for orchestrating forked worker
processes with a compact, strongly-typed API. It wraps low-level POSIX process
control primitives in a higher-level object model composed of a manager, worker
objects, immutable worker groups, typed signals, and named exceptions.
This package is designed for CLI-oriented workloads where you need explicit control over process fan-out, lifecycle supervision, output capture, and graceful shutdown. Typical scenarios include queue consumers, parallel task dispatchers, long-running daemons, and controlled background process trees.
Useful links
Highlights
- A single
ForkManagerorchestrates worker creation, waiting, and signaling. - Each
Workerexposes PID, status, exit code, termination signal, stdout, and error output. WorkerGroupoffers immutable grouping for batch coordination.Signalis a typed enum instead of a raw integer protocol.DefaultSignalHandlercan propagate master-process signals to the worker tree.- PSR-3 loggers can observe lifecycle and streamed output events.
- Worker output can be inspected before all workers finish.
Contents:
- Getting Started
- Usage
- Advanced Topics
- API Reference
- Links and References
-
FAQ
- Why does the manager throw on unsupported runtimes instead of running synchronously?
- Can I wait for every worker without storing each group?
- Can I signal only one worker?
- Can I read output before workers finish?
- Why is direct fwrite(STDOUT, ...) not captured?
- Can I reuse the same manager inside a worker to create nested workers?
- Does the library provide container aliases or singletons?
- Can I integrate the manager with a PSR-11 container?
- Can I inject my own logger?
- What exception should I catch if I only care about library-owned failures?
- Does this package work for standard HTTP request handling?
- Where should I start if I want a hands-on walkthrough?
- Compatibility