hasantayyar/forker

Split tasks into multiple forked processes.

dev-master 2014-09-02 13:03 UTC

This package is not auto-updated.

Last update: 2024-11-23 17:01:25 UTC


README

Build Status

Forker presents a simple interfacing for forking in PHP.

##What is different in this fork All same but this fork packed for composer.

Install

composer require hasantayyar/forker:dev-master

Getting Started

<?php
use Hasantayyar\Forker\Forker;
$servers = array('machine1.example.com', 'machine2.example.com');

/**
 * Run a shell command on an array of servers using SSH,
 * returning the output and exit code.
 */
function runCmd($command, $servers) {
    return Forker::map($servers,
    function($index, $server) use ($command) {
        $sshCommand = "ssh $server -c '$command' 2>&1";
        exec($sshCommand, $exitCode, $output);
        return array(
            'output' => implode("\n", $output),
            'exitCode' => $exitCode
        );
    });
}

$results = runCmd("hostname", $servers);
print_r($results);

Circle CI