Copied!

The ProgressBar provides helpers to display progress output.

CloneableFinalInstantiable
Constants
public Symfony\Component\Console\Helper\ProgressBar::FORMAT_DEBUG = 'debug'
public Symfony\Component\Console\Helper\ProgressBar::FORMAT_NORMAL = 'normal'
public Symfony\Component\Console\Helper\ProgressBar::FORMAT_VERBOSE = 'verbose'
public Symfony\Component\Console\Helper\ProgressBar::FORMAT_VERY_VERBOSE = 'very_verbose'
Methods
public __construct(Symfony\Component\Console\Output\OutputInterface $output, int $max = 0, float $minSecondsBetweenRedraws = 0.04)
 
  • param int $max Maximum steps (0 if unknown)
public advance(int $step = 1) : void
 

Advances the progress output X steps.

  • param int $step Number of steps to advance
public clear() : void
 

Removes the progress bar from the current line.

This is useful if you wish to write some output while a progress bar is running. Call display() to show the progress bar again.

public display() : void
 

Outputs the current progress string.

public finish() : void
 

Finishes the progress output.

public getBarCharacter() : string
public getBarOffset() : float
public getBarWidth() : int
public getEmptyBarCharacter() : string
public getEstimated() : float
public static getFormatDefinition(string $name) : ?string
 

Gets the format for a given name.

  • param string $name The format name
public getMaxSteps() : int
public getMessage(string $name = 'message') : ?string
public getPlaceholderFormatter(string $name) : ?callable
 

Gets the placeholder formatter for a given name.

  • param string $name The placeholder name (including the delimiter char like %)
public static getPlaceholderFormatterDefinition(string $name) : ?callable
 

Gets the placeholder formatter for a given name.

  • param string $name The placeholder name (including the delimiter char like %)
public getProgress() : int
public getProgressCharacter() : string
public getProgressPercent() : float
public getRemaining() : float
public getStartTime() : int
public iterate(iterable $iterable, ?int $max = NULL) : iterable
 

Returns an iterator that will automatically update the progress bar when iterated.

  • template
  • template
  • param iterable<\TKey,\TValue> $iterable
  • param int|null $max Number of steps to complete the bar (0 if indeterminate), if null it will be inferred from $iterable
  • return iterable<\TKey,\TValue>
public maxSecondsBetweenRedraws(float $seconds) : void
public minSecondsBetweenRedraws(float $seconds) : void
public setBarCharacter(string $char) : void
public setBarWidth(int $size) : void
public setEmptyBarCharacter(string $char) : void
public setFormat(string $format) : void
public static setFormatDefinition(string $name, string $format) : void
 

Sets a format for a given name.

This method also allow you to override an existing format.

  • param string $name The format name
  • param string $format A format string
public setMaxSteps(?int $max) : void
public setMessage(string $message, string $name = 'message') : void
 

Associates a text with a named placeholder.

The text is displayed when the progress bar is rendered but only when the corresponding placeholder is part of the custom format line (by wrapping the name with %).

  • param string $message The text to associate with the placeholder
  • param string $name The name of the placeholder
public setOverwrite(bool $overwrite) : void
 

Sets whether to overwrite the progressbar, false for new line.

public setPlaceholderFormatter(string $name, callable $callable) : void
 

Sets a placeholder formatter for a given name, for this instance only.

  • param callable $callable A PHP callable
public static setPlaceholderFormatterDefinition(string $name, callable $callable) : void
 

Sets a placeholder formatter for a given name, globally for all instances of ProgressBar.

This method also allow you to override an existing placeholder.

  • param string $name The placeholder name (including the delimiter char like %)
  • param callable $callable A PHP callable
public setProgress(int $step) : void
public setProgressCharacter(string $char) : void
public setRedrawFrequency(?int $freq) : void
 

Sets the redraw frequency.

  • param int|null $freq The frequency in steps
public start(?int $max = NULL, int $startAt = 0) : void
 

Starts the progress output.

  • param int|null $max Number of steps to complete the bar (0 if indeterminate), null to leave unchanged
  • param int $startAt The starting point of the bar (useful e.g. when resuming a previously started bar)
Constants
private Symfony\Component\Console\Helper\ProgressBar::FORMAT_DEBUG_NOMAX = 'debug_nomax'
private Symfony\Component\Console\Helper\ProgressBar::FORMAT_NORMAL_NOMAX = 'normal_nomax'
private Symfony\Component\Console\Helper\ProgressBar::FORMAT_VERBOSE_NOMAX = 'verbose_nomax'
private Symfony\Component\Console\Helper\ProgressBar::FORMAT_VERY_VERBOSE_NOMAX = 'very_verbose_nomax'
Properties
private string $barChar
private int $barWidth = 28
private Symfony\Component\Console\Cursor $cursor
private string $emptyBarChar = '-'
private ?string $format = NULL
private static array $formats
private static array $formatters
private ?string $internalFormat = NULL
private float $lastWriteTime = 0
private ?int $max = NULL
private float $maxSecondsBetweenRedraws = 1
private array $messages = []
private float $minSecondsBetweenRedraws = 0
private Symfony\Component\Console\Output\OutputInterface $output
private bool $overwrite = true
private float $percent = 0
private array $placeholders = []
private ?string $previousMessage = NULL
private string $progressChar = '>'
private ?int $redrawFreq = 1
private int $startingStep = 0
private int $startTime
private int $step = 0
private int $stepWidth
private Symfony\Component\Console\Terminal $terminal
private int $writeCount = 0
Methods
private buildLine() : string
private determineBestFormat() : string
private getStepWidth() : int
private static initFormats() : array
private static initPlaceholderFormatters() : array
private overwrite(string $message) : void
 

Overwrites a previous message to the output.

private setRealFormat(string $format) : void
Properties
private static array $formats
private static array $formatters
Methods
public static getFormatDefinition(string $name) : ?string
 

Gets the format for a given name.

  • param string $name The format name
public static getPlaceholderFormatterDefinition(string $name) : ?callable
 

Gets the placeholder formatter for a given name.

  • param string $name The placeholder name (including the delimiter char like %)
private static initFormats() : array
private static initPlaceholderFormatters() : array
public static setFormatDefinition(string $name, string $format) : void
 

Sets a format for a given name.

This method also allow you to override an existing format.

  • param string $name The format name
  • param string $format A format string
public static setPlaceholderFormatterDefinition(string $name, callable $callable) : void
 

Sets a placeholder formatter for a given name, globally for all instances of ProgressBar.

This method also allow you to override an existing placeholder.

  • param string $name The placeholder name (including the delimiter char like %)
  • param callable $callable A PHP callable
© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration