Skip to content

Instantly share code, notes, and snippets.

@mariusbalcytis
Created April 19, 2017 19:38
Show Gist options
  • Save mariusbalcytis/5b28910592485b69fe9a26b926913afb to your computer and use it in GitHub Desktop.
Save mariusbalcytis/5b28910592485b69fe9a26b926913afb to your computer and use it in GitHub Desktop.
<?php
<<<CONFIG
packages:
- "symfony/process: 3.3.x-dev"
CONFIG;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;
$executable = 'echo';
$arguments = ['test1', 'test2'];
$processBuilder = new ProcessBuilder();
$processBuilder->setArguments(array_merge(
[$executable],
$arguments
));
$process = $processBuilder->getProcess();
if (DIRECTORY_SEPARATOR !== '\\') {
$process->setCommandLine('exec ' . $process->getCommandLine());
}
$process->mustRun(function ($type, $buffer) {
echo $buffer;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment