Open
Description
Description
Progress bars are a great way to provide feedback to somebody using a Symfony command in a terminal. However, when running the same Symfony command in a cronjob, you will often get logs flooded by the output of the same progress bar. I found that in my case, checking for the TERM
env variable seemed like a reliable way to do this, and I'm proposing this is done internally by Symfony, transparently.
Example
Before
if (getenv('TERM') !== false) {
$progressBar = new ProgressBar($output);
$callback = function () use ($progressBar): void {
$progressBar->advance();
};
} else {
$callback = null;
}
($this->import)($callback);
if (isset($progressBar)) {
$progressBar->finish();
}
After
$progressBar = new ProgressBar($output);
$callback = function () use ($progressBar): void {
$progressBar->advance(); // does nothing if TERM is not set
};
($this->import)($callback);
$progressBar->finish(); // does nothing if TERM is not set