Skip to content

Class for running separate processes of PHP CLI scripts

License

Notifications You must be signed in to change notification settings

php-strict/script-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Script runner

Software License Build Status codecov Codacy Badge

Class for running PHP CLI script in several separate processes.

Requirements

  • PHP >= 7.1

Install

Use class as standalone:

require 'ScriptRunner.php';
use PhpStrict\ScriptRunner\ScriptRunner;

Install with Composer:

composer require php-strict/script-runner

Usage

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).

Tests

To execute the test suite, you'll need Codeception.

vendor/bin/codecept run

Releases

No releases published

Packages

 
 
 

Languages