2017 © Pedro Peláez
 

library saxulum-processes-executor

Saxulum Processes Executor

image

saxulum/saxulum-processes-executor

Saxulum Processes Executor

  • Sunday, June 17, 2018
  • by dominikzogg
  • Repository
  • 1 Watchers
  • 6 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

saxulum-processes-executor

Build Status Scrutinizer Code Quality Code Coverage Total Downloads Monthly Downloads Latest Stable Version Latest Unstable Version, (*1)

Description

A simple to use process executor., (*2)

Requirements

  • php: ~7.0
  • psr/log: ~1.0
  • symfony/process: ~4.0|~3.0|~2.8

Installation

Through Composer as [saxulum/saxulum-processes-executor][1]., (*3)

Usage

Simple use without any callbacks

```{.php} <?php, (*4)

use Symfony\Component\Process\Process; use Saxulum\ProcessesExecutor\ProcessesExecutor;, (*5)

$processes = [ new Process('php subprocess1.php'), new Process('php subprocess2.php'), new Process('php subprocess3.php'), new Process('php subprocess4.php'), new Process('php subprocess5.php'), ];, (*6)

$startedCommandLines = [];, (*7)

$executor = new ProcessesExecutor(); $executor->execute($processes);, (*8)



### With start callback (get called onces per process) ```{.php} <?php use Symfony\Component\Process\Process; use Saxulum\ProcessesExecutor\ProcessesExecutor; $processes = [ new Process('php subprocess1.php'), new Process('php subprocess2.php'), new Process('php subprocess3.php'), new Process('php subprocess4.php'), new Process('php subprocess5.php'), ]; $startedCommandLines = []; $executor = new ProcessesExecutor(); $executor->execute( $processes, function (Process $process, $key) use (&$startedProcesses) { $startedCommandLines[$key] = $process->getCommandLine(); } );

With iteration callback (get called onces per iteration)

```{.php} <?php, (*9)

use Symfony\Component\Process\Process; use Saxulum\ProcessesExecutor\ProcessesExecutor;, (*10)

$processes = [ new Process('php subprocess1.php'), new Process('php subprocess2.php'), new Process('php subprocess3.php'), new Process('php subprocess4.php'), new Process('php subprocess5.php'), ];, (*11)

$outputs = []; $errorOutputs = [];, (*12)

$executor = new ProcessesExecutor(); $executor->execute( $processes, null, function (array $processes) use (&$outputs, &$errorOutputs) { foreach ($processes as $key => $process) { /** @var Process $process */ if ('' !== $output = $process->getIncrementalOutput()) { if (!isset($outputs[$key])) { $outputs[$key] = ''; }, (*13)

            $outputs[$key] .= $output;
        }
        if ('' !== $errorOutput = $process->getIncrementalErrorOutput()) {
            if (!isset($outputs[$key])) {
                $errorOutputs[$key] = '';
            }

            $errorOutputs[$key] .= $errorOutput;
        }
    }
}

);, (*14)


### With finish callback (get called onces per process) ```{.php} <?php use Symfony\Component\Process\Process; use Saxulum\ProcessesExecutor\ProcessesExecutor; $processes = [ new Process('php subprocess1.php'), new Process('php subprocess2.php'), new Process('php subprocess3.php'), new Process('php subprocess4.php'), new Process('php subprocess5.php'), ]; $outputs = []; $errorOutputs = []; $executor = new ProcessesExecutor(); $executor->execute( $processes, null, null, function (Process $process, $key) use (&$outputs, &$errorOutputs) { if ('' !== $output = $process->getOutput()) { $outputs[$key] = $output; } if ('' !== $errorOutput = $process->getErrorOutput()) { $errorOutputs[$key] = $errorOutput; } } );

Dominik Zogg 2016, (*15)

The Versions

17/06 2018

dev-master

9999999-dev

Saxulum Processes Executor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

command symfony saxulum processes-executor

17/06 2018

1.0.0

1.0.0.0

Saxulum Processes Executor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

command symfony saxulum processes-executor

22/09 2016

1.0.0-alpha5

1.0.0.0-alpha5

Saxulum Processes Executor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

command symfony saxulum processes-executor

20/09 2016

1.0.0-alpha4

1.0.0.0-alpha4

Saxulum Processes Executor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

command symfony saxulum processes-executor

20/09 2016

1.0.0-alpha3

1.0.0.0-alpha3

Saxulum Processes Executor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

command symfony saxulum processes-executor

18/09 2016

1.0.0-alpha2

1.0.0.0-alpha2

Saxulum Processes Executor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

command symfony saxulum processes-executor

17/09 2016

1.0.0-alpha

1.0.0.0-alpha

Saxulum Processes Executor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

command symfony saxulum processes-executor