PHPackages                             innmind/process-manager - 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. innmind/process-manager

Abandoned → [innmind/mantle](/?search=innmind%2Fmantle)ArchivedLibrary

innmind/process-manager
=======================

Library to work with sub-processes

4.2.0(2y ago)0461↑233.3%MITPHPPHP ~8.2

Since Jul 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Innmind/ProcessManager)[ Packagist](https://packagist.org/packages/innmind/process-manager)[ Docs](http://github.com/Innmind/ProcessManager)[ RSS](/packages/innmind-process-manager/feed)WikiDiscussions develop Synced today

READMEChangelog (2)Dependencies (6)Versions (11)Used By (0)

ProcessManager
==============

[](#processmanager)

[![Build Status](https://github.com/Innmind/ProcessManager/workflows/CI/badge.svg?branch=master)](https://github.com/Innmind/ProcessManager/actions?query=workflow%3ACI)[![codecov](https://camo.githubusercontent.com/3f436a492893bb3c6316a2fc4555c8a8bd1b8d075c51101c8f1816265f4914bc/68747470733a2f2f636f6465636f762e696f2f67682f496e6e6d696e642f50726f636573734d616e616765722f6272616e63682f646576656c6f702f67726170682f62616467652e737667)](https://codecov.io/gh/Innmind/ProcessManager)[![Type Coverage](https://camo.githubusercontent.com/abbf210f220cda7370070efe67ff0efa208882f09560bd3ec381250ccfd30974/68747470733a2f2f73686570686572642e6465762f6769746875622f496e6e6d696e642f50726f636573734d616e616765722f636f7665726167652e737667)](https://shepherd.dev/github/Innmind/ProcessManager)

Simple library to execute code in parallel thanks to `pcntl_fork`.

Installation
------------

[](#installation)

```
composer require innmind/process-manager
```

Usage
-----

[](#usage)

```
use Innmind\ProcessManager\{
    Manager\Parallel,
    Runner\SubProcess,
};
use Innmind\OperatingSystem\Factory;
use Innmind\Immutable\{
    Sequence,
    Str,
};
use GuzzleHttp\Client;

$urls = Sequence::strings(
    'http://google.com',
    'http://github.com',
    'http://wikipedia.org'
);
$http = new Client;
$os = Factory::buid();
$runner = new SubProcess($os->process());
$crawl = $urls->reduce(
    Parallel::of($runner),
    static function(Parallel $parallel, string $url) use ($http): Parallel {
        return $parallel->schedule(static function() use ($http, $url): void {
            \file_put_contents(
                '/tmp/'.md5($url),
                (string) $http->get($url)->getBody(),
            );
        });
    }
);
$crawling = $crawl->start()->match(
    static fn($crawling) => $crawling,
    static fn() => throw new \RuntimeException('Failed to start crawlers'),
);
echo 'These urls are being crawled in parallel: '.Str::of(', ')->join($urls);
$crawling->wait()->match(
    static fn() => null, // finished
    static fn() => throw new \RuntimeException('A process failed'),
);
```

This sample will crawl the 3 urls in parallel via sub processes.

**Important**: with this code you cannot return values, if you want to return content to the parent process you need to implement IPC over socket or shared memory (this may be implemented in future versions).

### `Pool`

[](#pool)

`Pool` implements the same interface as `Parallel`, but you need to specify the maximum number of sub processes you want to allow, ie `Pool::of(2, $runner, $sockets)` will allow at most 2 sub processes in parallel.

**Important**: when you start your pool only the first `n` scheduled functions will be called, you absolutely need to call the `wait` method so the remaining functions are called.

Example:

```
use Innmind\ProcessManager\Manager\Pool;

$pool = Pool::of(2, $runner, $os->sockets())
    ->schedule(function() {
        sleep(10);
    })
    ->schedule(function() {
        sleep(5);
    })
    ->schedule(function() {
        sleep(60);
    });
// no process started yet, same behaviour as Parallel
$running = $pool->start()->match(
    static fn($running) => $running,
    static fn() => throw new \RuntimeException,
);
// first two functions are started as sub processes
/*
do some code that last more than 10 seconds...
 */
// third function still not started
$pool->wait()->match( // this will run all the remaining functions
    static fn() => null, // finished
    static fn() => throw new \RuntimeException,
);
```

###  Health Score

35

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 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 ~281 days

Recently: every ~330 days

Total

9

Last Release

911d ago

Major Versions

1.1.0 → 2.0.02019-01-12

2.1.0 → 3.0.02020-02-09

3.1.0 → 4.0.02022-07-01

PHP version history (6 changes)1.0.0PHP ~7.1

2.0.0PHP ~7.2

3.0.0PHP ~7.4

3.1.0PHP ~7.4|~8.0

4.0.0PHP ~8.1

4.2.0PHP ~8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/851425?v=4)[Baptiste Langlade](/maintainers/Baptouuuu)[@Baptouuuu](https://github.com/Baptouuuu)

---

Top Contributors

[![Baptouuuu](https://avatars.githubusercontent.com/u/851425?v=4)](https://github.com/Baptouuuu "Baptouuuu (94 commits)")

---

Tags

pcntl

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/innmind-process-manager/health.svg)

```
[![Health](https://phpackages.com/badges/innmind-process-manager/health.svg)](https://phpackages.com/packages/innmind-process-manager)
```

###  Alternatives

[misterion/ko-process

Simple pcntl fork wrapper and process manager

184336.2k6](/packages/misterion-ko-process)[duncan3dc/fork-helper

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

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

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

16961.5k2](/packages/arara-process)[mkraemer/react-pcntl

PCNTL bindings for ReactPHP

57288.7k9](/packages/mkraemer-react-pcntl)[phlib/console-process

Console implementation.

1833.1k1](/packages/phlib-console-process)[misterion/ko-worker

Ko-worker project is a base to develop amqp based message dispatchers

2713.4k](/packages/misterion-ko-worker)

PHPackages © 2026

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