Skip to content

Instantly share code, notes, and snippets.

@mariusbalcytis
Created April 19, 2017 19:37
Show Gist options
  • Save mariusbalcytis/65b5799db0c04f0f82eb97c2be77db40 to your computer and use it in GitHub Desktop.
Save mariusbalcytis/65b5799db0c04f0f82eb97c2be77db40 to your computer and use it in GitHub Desktop.
<?php
<<<CONFIG
packages:
- "symfony/process: 3.2"
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