Documentation

ProgressBar
in package

FinalYes

The ProgressBar provides helpers to display progress output.

Tags
author

Fabien Potencier fabien@symfony.com

author

Chris Jones leeked@gmail.com

Table of Contents

Properties

$barChar  : mixed
$barWidth  : mixed
$emptyBarChar  : mixed
$format  : mixed
$formatLineCount  : mixed
$formats  : mixed
$formatters  : mixed
$internalFormat  : mixed
$lastWriteTime  : mixed
$max  : mixed
$maxSecondsBetweenRedraws  : mixed
$messages  : mixed
$minSecondsBetweenRedraws  : mixed
$output  : mixed
$overwrite  : mixed
$percent  : mixed
$previousMessage  : mixed
$progressChar  : mixed
$redrawFreq  : mixed
$startTime  : mixed
$step  : mixed
$stepWidth  : mixed
$terminal  : mixed
$writeCount  : mixed

Methods

__construct()  : mixed
advance()  : mixed
Advances the progress output X steps.
clear()  : void
Removes the progress bar from the current line.
display()  : void
Outputs the current progress string.
finish()  : void
Finishes the progress output.
getBarCharacter()  : string
getBarOffset()  : int
getBarWidth()  : int
getEmptyBarCharacter()  : string
getFormatDefinition()  : string|null
Gets the format for a given name.
getMaxSteps()  : int
getMessage()  : mixed
getPlaceholderFormatterDefinition()  : callable|null
Gets the placeholder formatter for a given name.
getProgress()  : int
getProgressCharacter()  : string
getProgressPercent()  : float
getStartTime()  : int
iterate()  : iterable<string|int, mixed>
Returns an iterator that will automatically update the progress bar when iterated.
maxSecondsBetweenRedraws()  : void
minSecondsBetweenRedraws()  : void
setBarCharacter()  : mixed
setBarWidth()  : mixed
setEmptyBarCharacter()  : mixed
setFormat()  : mixed
setFormatDefinition()  : void
Sets a format for a given name.
setMaxSteps()  : mixed
setMessage()  : mixed
Associates a text with a named placeholder.
setOverwrite()  : mixed
Sets whether to overwrite the progressbar, false for new line.
setPlaceholderFormatterDefinition()  : void
Sets a placeholder formatter for a given name.
setProgress()  : mixed
setProgressCharacter()  : mixed
setRedrawFrequency()  : mixed
Sets the redraw frequency.
start()  : mixed
Starts the progress output.
buildLine()  : string
determineBestFormat()  : string
getStepWidth()  : int
initFormats()  : array<string|int, mixed>
initPlaceholderFormatters()  : array<string|int, mixed>
overwrite()  : void
Overwrites a previous message to the output.
setRealFormat()  : mixed

Properties

$maxSecondsBetweenRedraws

private mixed $maxSecondsBetweenRedraws = 1

$minSecondsBetweenRedraws

private mixed $minSecondsBetweenRedraws = 0

Methods

__construct()

public __construct(OutputInterface $output[, int $max = 0 ][, float $minSecondsBetweenRedraws = 0.1 ]) : mixed
Parameters
$output : OutputInterface
$max : int = 0

Maximum steps (0 if unknown)

$minSecondsBetweenRedraws : float = 0.1

advance()

Advances the progress output X steps.

public advance([int $step = 1 ]) : mixed
Parameters
$step : int = 1

Number of steps to advance

clear()

Removes the progress bar from the current line.

public clear() : void

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

display()

Outputs the current progress string.

public display() : void

finish()

Finishes the progress output.

public finish() : void

getBarCharacter()

public getBarCharacter() : string
Return values
string

getBarOffset()

public getBarOffset() : int
Return values
int

getBarWidth()

public getBarWidth() : int
Return values
int

getEmptyBarCharacter()

public getEmptyBarCharacter() : string
Return values
string

getFormatDefinition()

Gets the format for a given name.

public static getFormatDefinition(string $name) : string|null
Parameters
$name : string

The format name

Return values
string|null

A format string

getMaxSteps()

public getMaxSteps() : int
Return values
int

getMessage()

public getMessage([string $name = 'message' ]) : mixed
Parameters
$name : string = 'message'

getPlaceholderFormatterDefinition()

Gets the placeholder formatter for a given name.

public static getPlaceholderFormatterDefinition(string $name) : callable|null
Parameters
$name : string

The placeholder name (including the delimiter char like %)

Return values
callable|null

A PHP callable

getProgress()

public getProgress() : int
Return values
int

getProgressCharacter()

public getProgressCharacter() : string
Return values
string

getProgressPercent()

public getProgressPercent() : float
Return values
float

getStartTime()

public getStartTime() : int
Return values
int

iterate()

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

public iterate(iterable<string|int, mixed> $iterable[, int|null $max = null ]) : iterable<string|int, mixed>
Parameters
$iterable : iterable<string|int, mixed>
$max : int|null = null

Number of steps to complete the bar (0 if indeterminate), if null it will be inferred from $iterable

Return values
iterable<string|int, mixed>

maxSecondsBetweenRedraws()

public maxSecondsBetweenRedraws(float $seconds) : void
Parameters
$seconds : float

minSecondsBetweenRedraws()

public minSecondsBetweenRedraws(float $seconds) : void
Parameters
$seconds : float

setBarCharacter()

public setBarCharacter(string $char) : mixed
Parameters
$char : string

setBarWidth()

public setBarWidth(int $size) : mixed
Parameters
$size : int

setEmptyBarCharacter()

public setEmptyBarCharacter(string $char) : mixed
Parameters
$char : string

setFormat()

public setFormat(string $format) : mixed
Parameters
$format : string

setFormatDefinition()

Sets a format for a given name.

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

This method also allow you to override an existing format.

Parameters
$name : string

The format name

$format : string

A format string

setMaxSteps()

public setMaxSteps(int $max) : mixed
Parameters
$max : int

setMessage()

Associates a text with a named placeholder.

public setMessage(string $message[, string $name = 'message' ]) : mixed

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
$message : string

The text to associate with the placeholder

$name : string = 'message'

The name of the placeholder

setOverwrite()

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

public setOverwrite(bool $overwrite) : mixed
Parameters
$overwrite : bool

setPlaceholderFormatterDefinition()

Sets a placeholder formatter for a given name.

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

This method also allow you to override an existing placeholder.

Parameters
$name : string

The placeholder name (including the delimiter char like %)

$callable : callable

A PHP callable

setProgress()

public setProgress(int $step) : mixed
Parameters
$step : int

setProgressCharacter()

public setProgressCharacter(string $char) : mixed
Parameters
$char : string

setRedrawFrequency()

Sets the redraw frequency.

public setRedrawFrequency(int|null $freq) : mixed
Parameters
$freq : int|null

The frequency in steps

start()

Starts the progress output.

public start([int|null $max = null ]) : mixed
Parameters
$max : int|null = null

Number of steps to complete the bar (0 if indeterminate), null to leave unchanged

buildLine()

private buildLine() : string
Return values
string

determineBestFormat()

private determineBestFormat() : string
Return values
string

getStepWidth()

private getStepWidth() : int
Return values
int

initFormats()

private static initFormats() : array<string|int, mixed>
Return values
array<string|int, mixed>

initPlaceholderFormatters()

private static initPlaceholderFormatters() : array<string|int, mixed>
Return values
array<string|int, mixed>

overwrite()

Overwrites a previous message to the output.

private overwrite(string $message) : void
Parameters
$message : string

setRealFormat()

private setRealFormat(string $format) : mixed
Parameters
$format : string

        
On this page

Search results