Class for running PHP CLI script in several separate processes.
- PHP >= 7.1
Use class as standalone:
require 'ScriptRunner.php';
use PhpStrict\ScriptRunner\ScriptRunner;
Install with Composer:
composer require php-strict/script-runner
use PhpStrict\ScriptRunner\ScriptRunner;
//params: path_to_script, processes count (if omitted then system CPU cores count will be used)
$sr = new ScriptRunner('script.php', 4);
$sr->run();
May be used with CooperativeWorker to split one sequential process into several separated processes and keep them from collisions and making the same job twice. For eaxample it is possible to convert process of parsing log files from cycle (where log files parsing one-by-one) into several separated processes where each process take job from common temporary storage (queue).
To execute the test suite, you'll need Codeception.
vendor/bin/codecept run