Console ProgressBar and Text

The query was; How to set the Text Label on the progressbar in console mode.
The answer by Michael “Ray” Rehbein: You want to set the ‘elements’ option of the adapter.

http://framework.zend.com/manual/en/zend.progressbar.html#zend.progressbar.adapter.console


$pbAdapter = new Zend_ProgressBar_Adapter_Console(
array('elements'=>
array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT,
Zend_ProgressBar_Adapter_Console::ELEMENT_BAR,
Zend_ProgressBar_Adapter_Console::ELEMENT_ETA,
Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT)
)
);

$progressBar = new Zend_ProgressBar($pbAdapter, 0, 10);

for ($i = 0; $i < 10; $i++) {
sleep(1);
$progressBar->update($i, "Iteration: {$i}"); } $progressBar->finish();
}

Quite nifty.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.