PHPackages                             fast-forward/fork - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. fast-forward/fork

ActiveLibrary[Queues &amp; Workers](/categories/queues)

fast-forward/fork
=================

A process manager for PHP that allows you to run multiple processes in parallel using the fork system call.

v1.0.1(3mo ago)0284[1 issues](https://github.com/php-fast-forward/fork/issues)1MITPHPPHP ^8.3CI passing

Since Apr 4Pushed 2mo agoCompare

[ Source](https://github.com/php-fast-forward/fork)[ Packagist](https://packagist.org/packages/fast-forward/fork)[ Docs](https://github.com/php-fast-forward/fork)[ RSS](/packages/fast-forward-fork/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (4)Versions (3)Used By (1)

Fast Forward Fork
=================

[](#fast-forward-fork)

A PHP 8.3+ library for orchestrating forked workers with typed signals, immutable worker groups, captured worker output, and PSR-3 logging.

[![PHP Version](https://camo.githubusercontent.com/c9b19f1cbf8aefb8c278c8b5d392b64401164a08fced6ccbf376b32135d6714f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net/releases/)[![Composer Package](https://camo.githubusercontent.com/d9c67f0075d0923055219d8b53293e934568c8fbe224f64aa4f85fb07364e3bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6d706f7365722d666173742d2d666f7277617264253246666f726b2d4632384431412e7376673f6c6f676f3d636f6d706f736572266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/fast-forward/fork)[![Tests](https://camo.githubusercontent.com/80f3a2a55dee045c2fee1c5c2ebd8c5e1967267d28d7a4dd85108419a6af984e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7068702d666173742d666f72776172642f666f726b2f74657374732e796d6c3f6c6f676f3d676974687562616374696f6e73266c6f676f436f6c6f723d7768697465266c6162656c3d746573747326636f6c6f723d323243353545)](https://github.com/php-fast-forward/fork/actions/workflows/tests.yml)[![Coverage](https://camo.githubusercontent.com/783041b70aa9cfca2a0969ddc49e11178a3367b14165ef787853fdc3075f43b3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d706870756e69742d3441444538303f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://php-fast-forward.github.io/fork/coverage/index.html)[![Docs](https://camo.githubusercontent.com/2fc32c646c202e49a0d4a61806a327663f55237d2e8af3850a12e2e79e23e48f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6465706c6f796d656e74732f7068702d666173742d666f72776172642f666f726b2f6769746875622d70616765733f6c6f676f3d72656164746865646f6373266c6f676f436f6c6f723d7768697465266c6162656c3d646f6373266c6162656c436f6c6f723d31453239334226636f6c6f723d333842444638267374796c653d666c6174)](https://php-fast-forward.github.io/fork/index.html)[![License](https://camo.githubusercontent.com/bda3d8e0625444bd997b6f27addfdc9bfd39319a78cec2f82060dba5be54ea32/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7068702d666173742d666f72776172642f666f726b3f636f6c6f723d363437343842)](LICENSE)[![GitHub Sponsors](https://camo.githubusercontent.com/d61f432861a7c60e0a9620738dffd3b884bcf392c86e48a2cc87ea57a077e90a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73706f6e736f72732f7068702d666173742d666f72776172643f6c6f676f3d67697468756273706f6e736f7273266c6f676f436f6c6f723d776869746526636f6c6f723d454334383939)](https://github.com/sponsors/php-fast-forward)

`fast-forward/fork` wraps `pcntl_fork()` and related POSIX primitives in a small, strongly-typed API that is easier to reason about in real applications. It gives you a single manager for orchestration, explicit worker objects for lifecycle inspection, immutable worker groups for batch coordination, and a default signal handler that can shut everything down cleanly.

✨ Features
----------

[](#-features)

- 🚀 PHP 8.3+ API with enums, readonly dependencies, and clear object boundaries.
- 🧵 `ForkManager` orchestration for spawning, waiting, and signaling workers.
- 👷 `Worker` objects with lifecycle state, exit code, termination signal, and captured output.
- 📦 Immutable `WorkerGroup` collections for batch `wait()` and `kill()` operations.
- 🛑 Typed `Signal` enum for readable signal delivery and signal-aware exit status handling.
- 🔔 Pluggable `SignalHandlerInterface` with a ready-to-use `DefaultSignalHandler`.
- 📝 PSR-3 logger integration for worker lifecycle and streamed output events.
- 📡 Partial output availability while workers are still running.
- 🧪 Ordered examples that go from basic usage to advanced coordination scenarios.
- ⚠️ Named library exceptions for invalid usage, logic violations, and runtime failures.

📦 Installation
--------------

[](#-installation)

```
composer require fast-forward/fork
```

### Runtime requirements

[](#runtime-requirements)

- PHP `^8.3`
- `psr/log` `^3.0`
- A runtime that exposes the process-control functions checked by `ForkManager::isSupported()`
- In practice, this means a Unix-like CLI runtime with `pcntl` and `posix` support enabled

The manager validates runtime support during construction. If the environment does not support forking safely, it throws `FastForward\Fork\Exception\RuntimeException`.

🛠️ Usage
--------

[](#️-usage)

### Basic usage

[](#basic-usage)

```
