yii\helpers\BaseConsole::startProgress PHP Méthode

startProgress() public static méthode

This bar will be updated by BaseConsole::updateProgress and my be ended by BaseConsole::endProgress. The following example shows a simple usage of a progress bar: php 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: startProgress
See also: updateProgress
See also: endProgress
public static startProgress ( integer $done, integer $total, string $prefix = '', integer | boolean $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()]].
    public static function startProgress($done, $total, $prefix = '', $width = null)
    {
        self::$_progressStart = time();
        self::$_progressWidth = $width;
        self::$_progressPrefix = $prefix;
        self::$_progressEta = null;
        self::$_progressEtaLastDone = 0;
        self::$_progressEtaLastUpdate = time();
        static::updateProgress($done, $total);
    }