spatie/fork
Run PHP code concurrently using lightweight process forking. Define multiple closures and execute them in parallel, collecting results in order. Requires PHP 8 with pcntl (CLI only) and posix extensions on Unix-like systems.
pcntl_fork wrappers or external services) while staying open-source and vendor-neutral.exec() or shell_exec() calls with a structured, maintainable concurrency layer.spatie/fork + Symfony Console).Adopt if:
Look elsewhere if:
fork() support; consider parallel-lint or Docker-based alternatives).make or Airflow.reactphp or queues are better.For Executives: "This package lets us run PHP tasks in parallel—like a mini supercomputer for our app—without adding complexity or cost. For example, we could process 10x more user uploads simultaneously or generate reports 10x faster during off-peak hours. It’s a lightweight, open-source solution that avoids vendor lock-in, and it’s perfect for CPU-heavy tasks where we’d otherwise need to spin up microservices or queues. Early adopters like [Example Company] use it to cut batch processing times by 70%."
For Engineering:
*"Spatie’s fork gives us a simple, battle-tested way to run PHP code concurrently using pcntl_fork. It’s ideal for:
artisan commands or scripts (e.g., spatie/fork + parallel-lint).For Developers:
*"This is like Promise.all() but for PHP processes. Need to run 100 image resizes? Do it in parallel instead of sequentially. Need to scrape 1000 URLs? Fire off 10 workers instead of waiting. It’s as simple as:
$results = Fork::new()
->run(function () { /* task 1 */ })
->run(function () { /* task 2 */ })
->wait();
No queues, no Docker, no magic. Just raw concurrency. Docs are solid, and the API is intuitive. Downside: Windows users will need a workaround."*
How can I help you explore Laravel packages today?