PHPackages                             ssigwart/process-pool - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. ssigwart/process-pool

ActiveLibrary[Queues &amp; Workers](/categories/queues)

ssigwart/process-pool
=====================

Process pool to send tasks to a background task.

v1.0.6(1y ago)117MITPHPPHP &gt;=7.0.0CI failing

Since May 31Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/ssigwart/process-pool)[ Packagist](https://packagist.org/packages/ssigwart/process-pool)[ Docs](https://github.com/ssigwart/process-pool)[ RSS](/packages/ssigwart-process-pool/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (7)Dependencies (1)Versions (8)Used By (0)

Process Pool Package
====================

[](#process-pool-package)

This package allows you to run a process pool. The pool will multiple background processes to handle messages to the pool. You can specific the minimum and maximum number of pool processes to run.

Creating a Pool
---------------

[](#creating-a-pool)

```
$minPoolSize = 1;
$maxPoolSize = 10;
$poolProcessCmd = 'php process.php';
$cwd = '/path/to/pool/process';
$pool = new ProcessPool($minPoolSize, $maxPoolSize, $poolProcessCmd, $cwd);
$pool->setMaxNumSpareProcesses(3);
```

Implementing a Pool Process
---------------------------

[](#implementing-a-pool-process)

The pool process should implement `ssigwart\ProcessPool\ProcessPoolProcessMessageHandlerInterface`. The `handleRequest` function should handle incoming requests. It can output to `stdout` and `stderr`, which can be read with `getStdoutResponse` and `getStderrResponse`.

Below is an example of what `/path/to/pool/process/process.php` might look like.

```
