1

I have following Symfony Process which calls a standard git clone command and writes the output in real-time:

$process = new Process(
    [
        'git',
        'clone',
        self::REPOSITORY_URL . $project . '.git',
        $destinationPath
    ]
);

$cli = $this->cli;
$process->run(static function ($type, $buffer) use ($cli) {
    if(Process::ERR === $type) {
        $cli->error($buffer);
    } else {
        $cli->print($buffer);
    }
});

What I get is the output Cloning into '/my/projects/project'..., but formatted as an error.

I was able to pinpoint, that $type always has the value 'err', even during non-error output.

I had this problem before, when I used $process->start() first. Apparently, the process was not considered as finished, therefore I could solve it with $process->wait(). But I didn't get the output in real-time, thus the usage of $process->run() now. I feel like there might be a way to work with wait() again, but I'm not sure how.

0 Answers0