PHP code example of saxulum / saxulum-processes-executor
1. Go to this page and download the library: Download saxulum/saxulum-processes-executor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
saxulum / saxulum-processes-executor example snippets
{.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);
{.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();
}
);
{.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,
function (array $processes) use (&$outputs, &$errorOutputs) {
foreach ($processes as $key => $process) {
/** @var Process $process */
if ('' !== $output = $process->getIncrementalOutput()) {
if (!isset($outputs[$key])) {
$outputs[$key] = '';
}
$outputs[$key] .= $output;
}
if ('' !== $errorOutput = $process->getIncrementalErrorOutput()) {
if (!isset($outputs[$key])) {
$errorOutputs[$key] = '';
}
$errorOutputs[$key] .= $errorOutput;
}
}
}
);
{.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;
}
}
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.