Skip to content

Instantly share code, notes, and snippets.

@Shaked
Created February 2, 2019 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shaked/7cc7541d1743c641c947c006c15903e9 to your computer and use it in GitHub Desktop.
Save Shaked/7cc7541d1743c641c947c006c15903e9 to your computer and use it in GitHub Desktop.
<?php
..
..
$cmd = 'docker build someimage';
$process = Process::fromShellCommandline($cmd);
$process->setTimeout(0);
$process->run(function ($type, $buffer) {
if (Process::ERR === $type) {
echo 'ERR > '.$buffer;
} else {
echo 'OUT > '.$buffer;
}
});
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
return $process->getOutput();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment