PHPackages                             wyrihaximus/react-child-process-closure - 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. wyrihaximus/react-child-process-closure

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

wyrihaximus/react-child-process-closure
=======================================

Run closures in ReactPHP Child Processes

1.2.0(4y ago)624.2k↓100%2[5 PRs](https://github.com/WyriHaximus/reactphp-child-process-closure/pulls)1MITMakefilePHP ^8 || ^7.4

Since May 28Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/WyriHaximus/reactphp-child-process-closure)[ Packagist](https://packagist.org/packages/wyrihaximus/react-child-process-closure)[ GitHub Sponsors](https://github.com/WyriHaximus)[ RSS](/packages/wyrihaximus-react-child-process-closure/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (10)Used By (1)

ReactPHP Child Process Messenger/Pool Closure child class
=========================================================

[](#reactphp-child-process-messengerpool-closure-child-class)

[![Linux Build Status](https://camo.githubusercontent.com/3ddcc2a6af9b819b919bb45a258a1044c52ecc8c181985125164c34affc1c139/68747470733a2f2f7472617669732d63692e6f72672f57797269486178696d75732f72656163747068702d6368696c642d70726f636573732d636c6f737572652e706e67)](https://travis-ci.org/WyriHaximus/reactphp-child-process-closure)[![Latest Stable Version](https://camo.githubusercontent.com/532fb1564fdf73ff335b4b9c48a8921209b0a92111d09aa19f5275a5817afd11/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f72656163742d6368696c642d70726f636573732d636c6f737572652f762f737461626c652e706e67)](https://packagist.org/packages/WyriHaximus/react-child-process-closure)[![Total Downloads](https://camo.githubusercontent.com/4a2f23540a94b8f8c8cbb027ebe8deb68a918083df4d4202c5e81d406bdcc0f8/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f72656163742d6368696c642d70726f636573732d636c6f737572652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/WyriHaximus/react-child-process-closure)[![Code Coverage](https://camo.githubusercontent.com/725b17b677769e1292bb932ba5cc8133419b9afeaf1589713a376988a8202790/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f57797269486178696d75732f72656163747068702d6368696c642d70726f636573732d636c6f737572652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/WyriHaximus/reactphp-child-process-closure/?branch=master)[![License](https://camo.githubusercontent.com/b3ba94dbf1efa3eaa8d11af1f46d6ace5204835d1e10444a8576eb81f5eb6d59/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f72656163742d6368696c642d70726f636573732d636c6f737572652f6c6963656e73652e706e67)](https://packagist.org/packages/wyrihaximus/react-child-process-closure)[![PHP 7 ready](https://camo.githubusercontent.com/f4b855d2d936bd979fb67ea6285a7da63a831aa7c6b2e72fde692332477149a6/687474703a2f2f7068703772656164792e74696d6573706c696e7465722e63682f57797269486178696d75732f72656163747068702d6368696c642d70726f636573732d636c6f737572652f62616467652e737667)](https://travis-ci.org/WyriHaximus/reactphp-child-process-closure)

Run closures in a child process messenger or pool

### Installation

[](#installation)

To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `~`.

```
composer require wyrihaximus/react-child-process-closure

```

Usage
-----

[](#usage)

Run a closure on the child process and get the results. (Note that results have to be a JSON serializable array.)

```
use React\EventLoop\Factory as EventLoopFactory;
use WyriHaximus\React\ChildProcess\Closure\ClosureChild;
use WyriHaximus\React\ChildProcess\Closure\MessageFactory;
use WyriHaximus\React\ChildProcess\Messenger\Factory as MessengerFactory;
use WyriHaximus\React\ChildProcess\Messenger\Messages\Payload;
use WyriHaximus\React\ChildProcess\Messenger\Messenger;

$loop = EventLoopFactory::create();

MessengerFactory::parentFromClass(ClosureChild::class, $loop)->then(function (Messenger $messenger) use ($loop) {
    $messenger->rpc(MessageFactory::rpc(function () {
        return resolve(['time' => time()]);
    })->done(function (Payload $payload) {
        echo 'Time in the child process: ', $payload['time'], PHP_EOL;
    });
});

$loop->run();
```

The usage example above also works with [`wyrihaximus/react-child-process-pool`](https://github.com/wyrihaximus/reactphp-child-process-pool#flexible), just be sure to use `WyriHaximus\React\ChildProcess\Closure\MessageFactory` to create the RPC messages as shown in the example.

Examples
--------

[](#examples)

For more examples see the [examples](https://github.com/WyriHaximus/reactphp-child-process-closure/tree/master/examples) directory

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

Copyright 2017 [Cees-Jan Kiewiet](http://wyrihaximus.net/)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance43

Moderate activity, may be stable

Popularity29

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~523 days

Total

4

Last Release

1699d ago

PHP version history (3 changes)1.0.0PHP ^7.0

1.0.1PHP ^7.2

1.2.0PHP ^8 || ^7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/147145?v=4)[Cees-Jan Kiewiet](/maintainers/WyriHaximus)[@WyriHaximus](https://github.com/WyriHaximus)

---

Top Contributors

[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (44 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (21 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (18 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (4 commits)")[![bartvanhoutte](https://avatars.githubusercontent.com/u/4867154?v=4)](https://github.com/bartvanhoutte "bartvanhoutte (1 commits)")

---

Tags

child-processclosurecpu-offloadhacktoberfestphpphp7reactphp

### Embed Badge

![Health badge](/badges/wyrihaximus-react-child-process-closure/health.svg)

```
[![Health](https://phpackages.com/badges/wyrihaximus-react-child-process-closure/health.svg)](https://phpackages.com/packages/wyrihaximus-react-child-process-closure)
```

###  Alternatives

[react/react

ReactPHP: Event-driven, non-blocking I/O with PHP.

9.1k3.6M63](/packages/react-react)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)[wyrihaximus/react-child-process-pool

Pool wyrihaximus/react-child-process-messenger processes

40244.4k5](/packages/wyrihaximus-react-child-process-pool)[wyrihaximus/react-child-process-messenger

Messenger decorator for react/child-process

32279.4k4](/packages/wyrihaximus-react-child-process-messenger)[wyrihaximus/react-cron

⏱️ Cronlike scheduler running inside the ReactPHP Event Loop

4050.6k](/packages/wyrihaximus-react-cron)[mention/retry

A Retry library for PHP

1324.5k](/packages/mention-retry)

PHPackages © 2026

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