Laurens Laman
Contributed by Laurens Laman in #57576

The Symfony Console component has become the standard way of creating CLI commands and applications in PHP. More than 11,000 open source projects use it, and it's close to 1 billion downloads since it was released in October 2011.

Rock-solid and mature components like this no longer add revolutionary new features, but in each Symfony version, we improve it with small quality-of-life and DX (developer experience) tweaks.

In Symfony 7.2, we improved the Console component to allow you to customize the finished indicator. When using a progress indicator to let the user know that the component is not stalled, by default, you see a rotating text spinner:

Symfony Console Command with No Finished Indicator

You can customize the progress indicator with your own spinner or animation. The main issue is that when the command finishes, it displays the last progress indicator used, which can vary each time you run the command. This inconsistency in the final result is often less than ideal.

In Symfony 7.2 we're improving this by showing ✔ as the finished indicator:

Symfony Console Command with Default Finished Indicator

You can fully customize this value with the new finishedIndicatorValue option. For example, you could show a different indicator based on the result of the command:

1
2
3
4
5
6
7
8
9
10
11
use Symfony\Component\Console\Helper\ProgressIndicator;
// ...

$progressIndicator = new ProgressIndicator($output, finishedIndicatorValue: '✅');

try {
    /* do some work here ... */
    $progressIndicator->finish('Finished');
} catch (\Exception) {
    $progressIndicator->finish('Failed', '🚨');
}

And this is how it looks when the command runs successfully:

Symfony Console Command with Custom Finished Indicator
Published in #Living on the edge