PHPackages                             pbergman/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. pbergman/fork

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pbergman/fork
=============

fork library

2.0.2(10y ago)118MITPHPPHP &gt;=5.4.0

Since Oct 23Pushed 10y ago1 watchersCompare

[ Source](https://github.com/pbergman/processes-fork)[ Packagist](https://packagist.org/packages/pbergman/fork)[ RSS](/packages/pbergman-fork/feed)WikiDiscussions 2.0 Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (8)Used By (0)

processes-fork 2.0
==================

[](#processes-fork-20)

a small wrapper to dispatch work to workers (child processes), it uses opis/closure to serialize closures and redis (subscribe/publish and list methods) to distribute the work. This works bit different then the old one because this one will fork children en send work to them instead of forking new children for every job.

\###Usage

```
require 'vendor/autoload.php';

$m = new \PBergman\Fork\Manager();

$m->setWorkers(10);

for ($i = 0; $i < 25; $i++) {
    $foo = rand(1,8);
    $m->addJob(function($redis, $logger) use ($foo) {
        $logger->info('sleeping ' . $foo);
        sleep($foo);
    });
}

$m->run();

```

will output something like

```
[2015-05-27 18:16:52] [10663] manager.DEBUG: Child spawned 10665 [1/10]
[2015-05-27 18:16:52] [10663] manager.DEBUG: Child spawned 10666 [2/10]
[2015-05-27 18:16:52] [10663] manager.DEBUG: Child spawned 10667 [3/10]
[2015-05-27 18:16:52] [10663] manager.DEBUG: Child spawned 10668 [4/10]
[2015-05-27 18:16:52] [10663] manager.DEBUG: Child spawned 10669 [5/10]
[2015-05-27 18:16:52] [10663] manager.DEBUG: Child spawned 10670 [6/10]
[2015-05-27 18:16:52] [10663] manager.DEBUG: Child spawned 10671 [7/10]
[2015-05-27 18:16:52] [10663] manager.DEBUG: Child spawned 10672 [8/10]
[2015-05-27 18:16:52] [10663] manager.DEBUG: Child spawned 10673 [9/10]
[2015-05-27 18:16:52] [10663] manager.DEBUG: Child spawned 10674 [10/10]
[2015-05-27 18:16:52] [10663] manager.DEBUG: Pushing job to queue ##MANAGER@10665
[2015-05-27 18:16:52] [10663] manager.DEBUG: Pushing job to queue ##MANAGER@10666
[2015-05-27 18:16:52] [10663] manager.DEBUG: Pushing job to queue ##MANAGER@10667
[2015-05-27 18:16:52] [10663] manager.DEBUG: Pushing job to queue ##MANAGER@10668
[2015-05-27 18:16:52] [10666] manager.INFO: sleeping 6
[2015-05-27 18:16:52] [10663] manager.DEBUG: Pushing job to queue ##MANAGER@10669
[2015-05-27 18:16:52] [10665] manager.INFO: sleeping 8
[2015-05-27 18:16:52] [10667] manager.INFO: sleeping 5
[2015-05-27 18:16:52] [10668] manager.INFO: sleeping 1

...........

[2015-05-27 18:17:07] [10663] manager.DEBUG: Child 10672 exited with code 0
[2015-05-27 18:17:07] [10671] manager.DEBUG: Job finished
[2015-05-27 18:17:07] [10671] manager.DEBUG: Cleaning up resources
[2015-05-27 18:17:07] [10663] manager.DEBUG: Pushing exit signal to ##MANAGER@10671
[2015-05-27 18:17:07] [10671] manager.DEBUG: Received exit signal, shutting down
[2015-05-27 18:17:09] [10674] manager.DEBUG: Job finished
[2015-05-27 18:17:09] [10674] manager.DEBUG: Cleaning up resources
[2015-05-27 18:17:09] [10663] manager.DEBUG: Pushing exit signal to ##MANAGER@10674
[2015-05-27 18:17:09] [10663] manager.DEBUG: Child 10669 exited with code 0
[2015-05-27 18:17:09] [10674] manager.DEBUG: Received exit signal, shutting down
[2015-05-27 18:17:09] [10663] manager.DEBUG: Child 10671 exited with code 0
[2015-05-27 18:17:09] [10663] manager.DEBUG: Child 10674 exited with code 0

```

\###Methods

\##\_\_construct(&lt;PBergman\\Fork\\Helper\\Redis&gt; $redis = null, &lt;Psr\\Log\\LoggerInterface&gt; $logger = null)

constructor

\##run()

will start dispatching work to children, is blocking till all work is done

\##setWorkers( $workers)

set the amount of workers to start, will shrink to size of jobs if there are more workers than work

\##setTimeoutIdle( $timeout\_idle)

set time out that a child will run idle (waiting for new work)

\##setGenerator(&lt;PBergman\\Fork\\Generator\\GeneratorInterface&gt; $generator)

set the generator, that is used to convert data to send over the redis message queue

\##addJob( $job)

add work to for child process, should be callable so closure or a class implementing \_\_invoke()

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~36 days

Recently: every ~53 days

Total

7

Last Release

4008d ago

Major Versions

1.1.0 → 2.02015-05-27

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce73225a1c546feb93edc48c4b5d514a909aecceddc0fe0a021d4a42d2077e09?d=identicon)[pbergman](/maintainers/pbergman)

---

Top Contributors

[![pbergman](https://avatars.githubusercontent.com/u/1193198?v=4)](https://github.com/pbergman "pbergman (89 commits)")

---

Tags

fork

### Embed Badge

![Health badge](/badges/pbergman-fork/health.svg)

```
[![Health](https://phpackages.com/badges/pbergman-fork/health.svg)](https://phpackages.com/packages/pbergman-fork)
```

###  Alternatives

[spatie/fork

A lightweight solution for running code concurrently in PHP

1.0k2.6M39](/packages/spatie-fork)[duncan3dc/fork-helper

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

73548.0k4](/packages/duncan3dc-fork-helper)[arara/process

Provides a better API to work with processes on Unix-like systems

16861.7k2](/packages/arara-process)[polonskiy/phproutine

Goroutines in PHP

60122.0k](/packages/polonskiy-phproutine)[lifo/php-ipc

Simple PHP Inter Process Communication (IPC) library

285.5k](/packages/lifo-php-ipc)[symfony-bundles/fork

SymfonyBundles Fork Library

178.0k](/packages/symfony-bundles-fork)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
