duncan3dc/fork-helper

Simple class to fork processes in PHP and allow multi-threading

Maintainers

👁 duncan3dc

Package info

github.com/duncan3dc/fork-helper

pkg:composer/duncan3dc/fork-helper

Statistics

Installs: 572 450

Dependents: 6

Suggesters: 4

Stars: 73

Open Issues: 3

2.6.0 2026-06-03 12:52 UTC

Requires

  • php: ^7.4 || ^8.0

Suggests

  • ext-pcntl: Needed to allow multi-threaded execution of code
  • ext-shmop: If pcntl is present then shmop is required to handle errors

Provides

None

Conflicts

None

Replaces

None

Apache-2.0 a560bb2b03f05ae1b46dcc466e3033822feb630b

processforkcontrolpcntlmulti-threading


README

Simple class to fork processes in PHP and allow multi-threading.

Full documentation is available at https://duncan3dc.github.io/fork-helper/
PHPDoc API documentation is also available at https://duncan3dc.github.io/fork-helper/api/

👁 release
👁 build
👁 coverage

Quick Example

Run some code asynchronously:

$fork = new \duncan3dc\Forker\Fork;

$fork->call(function () {
 for ($i = 1; $i <= 3; $i++) {
 echo "Process A - " . $i . "\n";
 sleep(1);
 }
});
$fork->call(function () {
 for ($i = 1; $i < 3; $i++) {
 echo "Process B - " . $i . "\n";
 sleep(1);
 }
});

sleep(1);
echo "Waiting for the threads to finish...\n";
$fork->wait();
echo "End\n";

Read more at https://duncan3dc.github.io/fork-helper/

Changelog

A Changelog has been available since version 2.0.0

Where to get help

Found a bug? Got a question? Just not sure how something works?
Please create an issue and I'll do my best to help out.
Alternatively you can catch me on Twitter

duncan3dc/fork-helper for enterprise

Available as part of the Tidelift Subscription

The maintainers of duncan3dc/fork-helper and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.