ProgressBar
class ProgressBar
The ProgressBar provides helpers to display progress output.
Methods
Details
__construct(OutputInterface $output, int $max = 0)
Parameters
OutputInterface | $output | An OutputInterface instance |
int | $max | Maximum steps (0 if unknown) |
Sets a placeholder formatter for a given name.
This method also allow you to override an existing placeholder.
Parameters
string | $name | The placeholder name (including the delimiter char like %) |
callable | $callable | A PHP callable |
Return Value
Gets the placeholder formatter for a given name.
Parameters
string | $name | The placeholder name (including the delimiter char like %) |
Return Value
callable|null | A PHP callable |
Sets a format for a given name.
This method also allow you to override an existing format.
Parameters
string | $name | The format name |
string | $format | A format string |
Return Value
Gets the format for a given name.
Parameters
string | $name | The format name |
Return Value
string|null | A format string |
setMessage(string $message, string $name = 'message')
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 %).
Parameters
string | $message | The text to associate with the placeholder |
string | $name | The name of the placeholder |
getMessage(string $name = 'message')
Parameters
int
getStartTime()
Return Value
int
getMaxSteps()
Return Value
int
getProgress()
Return Value
float
getProgressPercent()
Return Value
setBarWidth(int $size)
Parameters
int
getBarWidth()
Return Value
setBarCharacter(string $char)
Parameters
string
getBarCharacter()
Return Value
setEmptyBarCharacter(string $char)
Parameters
string
getEmptyBarCharacter()
Return Value
setProgressCharacter(string $char)
Parameters
string
getProgressCharacter()
Return Value
Parameters
setRedrawFrequency(int $freq)
Sets the redraw frequency.
Parameters
int | $freq | The frequency in steps |
start(int $max = null)
Starts the progress output.
Parameters
int | $max | Number of steps to complete the bar (0 if indeterminate), null to leave unchanged |
advance(int $step = 1)
Advances the progress output X steps.
Parameters
int | $step | Number of steps to advance |
setOverwrite(bool $overwrite)
Sets whether to overwrite the progressbar, false for new line.
Parameters
setProgress(int $step)
Parameters
setMaxSteps(int $max)
Parameters
void
finish()
Finishes the progress output.
Return Value
void
display()
Outputs the current progress string.
Return Value
void
clear()
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.
Return Value