W3cubDocs

/Symfony 4.1

ProgressBar

class ProgressBar

The ProgressBar provides helpers to display progress output.

Methods

__construct(OutputInterface $output, int $max = 0)
static void setPlaceholderFormatterDefinition(string $name, callable $callable)

Sets a placeholder formatter for a given name.

static callable|null getPlaceholderFormatterDefinition(string $name)

Gets the placeholder formatter for a given name.

static void setFormatDefinition(string $name, string $format)

Sets a format for a given name.

static string|null getFormatDefinition(string $name)

Gets the format for a given name.

setMessage(string $message, string $name = 'message')

Associates a text with a named placeholder.

getMessage(string $name = 'message')
int getStartTime()
int getMaxSteps()
int getProgress()
float getProgressPercent()
setBarWidth(int $size)
int getBarWidth()
setBarCharacter(string $char)
string getBarCharacter()
setEmptyBarCharacter(string $char)
string getEmptyBarCharacter()
setProgressCharacter(string $char)
string getProgressCharacter()
setFormat(string $format)
setRedrawFrequency(int $freq)

Sets the redraw frequency.

start(int $max = null)

Starts the progress output.

advance(int $step = 1)

Advances the progress output X steps.

setOverwrite(bool $overwrite)

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

setProgress(int $step)
setMaxSteps(int $max)
void finish()

Finishes the progress output.

void display()

Outputs the current progress string.

void clear()

Removes the progress bar from the current line.

Details

__construct(OutputInterface $output, int $max = 0)

Parameters

OutputInterface $output An OutputInterface instance
int $max Maximum steps (0 if unknown)

static void setPlaceholderFormatterDefinition(string $name, callable $callable)

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

void

static callable|null getPlaceholderFormatterDefinition(string $name)

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

static void setFormatDefinition(string $name, string $format)

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

void

static string|null getFormatDefinition(string $name)

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

string $name

int getStartTime()

Return Value

int

int getMaxSteps()

Return Value

int

int getProgress()

Return Value

int

float getProgressPercent()

Return Value

float

setBarWidth(int $size)

Parameters

int $size

int getBarWidth()

Return Value

int

setBarCharacter(string $char)

Parameters

string $char

string getBarCharacter()

Return Value

string

setEmptyBarCharacter(string $char)

Parameters

string $char

string getEmptyBarCharacter()

Return Value

string

setProgressCharacter(string $char)

Parameters

string $char

string getProgressCharacter()

Return Value

string

setFormat(string $format)

Parameters

string $format

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

bool $overwrite

setProgress(int $step)

Parameters

int $step

setMaxSteps(int $max)

Parameters

int $max

void finish()

Finishes the progress output.

Return Value

void

void display()

Outputs the current progress string.

Return Value

void

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

void

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Console/Helper/ProgressBar.html