helpers\BaseConsole startProgress()

startProgress() public static method

Starts display of a progress bar on screen.

This bar will be updated by updateProgress() and my be ended by endProgress().

The following example shows a simple usage of a progress bar:

Console::startProgress(0, 1000);
for ($n = 1; $n <= 1000; $n++) {
    usleep(1000);
    Console::updateProgress($n, 1000);
}
Console::endProgress();

Git clone like progress (showing only status information): `php Console::startProgress(0, 1000, 'Counting objects: ', false); for ($n = 1; $n <= 1000; $n++) {

usleep(1000);
Console::updateProgress($n, 1000);

} Console::endProgress("done." . PHP_EOL); `

See also:

public static void startProgress ( $done, $total, $prefix = '', $width = null )
$done integer

The number of items that are completed.

$total integer

The total value of items that are to be done.

$prefix string

An optional string to display before the progress bar. Default to empty string which results in no prefix to be displayed.

$width integer|boolean

Optional width of the progressbar. This can be an integer representing the number of characters to display for the progress bar or a float between 0 and 1 representing the percentage of screen with the progress bar may take. It can also be set to false to disable the bar and only show progress information like percent, number of items and ETA. If not set, the bar will be as wide as the screen. Screen size will be detected using getScreenSize().

doc_Yii
2016-10-30 17:04:40
Comments
Leave a Comment

Please login to continue.