Skip to content

About

PHP Process Pool (Using symfony process)

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

PHP Process Pool

License Latest Stable Version Continuous Integration

PHP Process Pool is a simple process pool using Symfony Process

System requirements:

  • PHP >= 8.4
  • proc_open

Installation:

composer require gemorroj/process-pool

Example:

use ProcessPool\ProcessPool;
use Symfony\Component\Process\Process;

function processGenerator(): \Generator {
    for ($i = 0; $i < 10; $i++) {
        yield new Process(['sleep', $i]);
    }
}

$pool = new ProcessPool(processGenerator());
$pool->wait(); // run all processes and wait for completion

run() is a streaming alternative to wait(): it yields a ProcessFinished event as soon as each process finishes.

foreach ($pool->run() as $event) {
    echo $event->getProcess()->getOutput();
}

About

PHP Process Pool (Using symfony process)

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages