Skip to content

Instantly share code, notes, and snippets.

@dator-zz
Created July 26, 2012 13:05
Show Gist options
  • Save dator-zz/3181937 to your computer and use it in GitHub Desktop.
Save dator-zz/3181937 to your computer and use it in GitHub Desktop.
<?php
class Client{
public function run(Repository $repository, $command)
{
$descriptors = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
$process = proc_open($this->getPath() . ' ' . $command, $descriptors, $pipes, $repository->getPath());
if (!is_resource($process)) {
throw new \RuntimeException('Unable to execute command: ' . $command);
}
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[2]);
if (!empty($stderr)) {
throw new \RuntimeException($stderr);
}
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);
proc_close($process);
return $stdout;
}
}
$tree = "";
$output = "";
$format = 'zip';
$fs = new Filesystem;
$c = new Client;
$fs->mkdir(dirname($output));
$c->run($this, "archive --format=$format --output=$output $tree");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment