I am using Symfonie's Process components, I am running a git clone command and would like to show a progressbar of it So far I have done this:
protected function cloneRepo(String $name)
{
$process = new Process(
"git clone {$this->getGitUrl(true)} {$name}" // does clone the repo works
);
$output = new ConsoleOutput();
// creates a new progress bar (100 units)
$progressBar = new ProgressBar($output, 100);
$process->run();
// starts and displays the progress bar
$progressBar->start();
$files = array_filter(explode("\n", $process->getOutput()), 'strlen');
for ($i = 0; $i < count($files); $i++) {
$progressBar->advance();
}
// ensures that the progress bar is at 100%
$progressBar->finish();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
}
But that only shows the finished progress bar after the clone is already finished