Zend_Console_ProgessBar in Incubator
Tuesday, August 19, 2008
I was bored the other day again, and thought about some tiny component, which would be as well helpful for some other developers. And there the idea came: Console applications need to show the status somehow, and what is a better way than a progressbar? Well, without telling much, you can kinda simply test it out yourself. Get Zend/Console/ProgressBar.php from the Incubator, and use the following test code:The result of that code will somewhat look like this:<?phprequire_once 'Zend/Console/ProgressBar.php';fwrite(STDOUT, "Please wait, while I sleep:\n");$progressBar = new Zend_Console_ProgressBar();for ($i = 1; $i <= 100; $i++) {$progressBar->update($i);usleep(1000000);}fwrite(STDOUT, "\n");

If you have any further improvements you want in this component, just tell me.
Features:
- Custom min/max values
- Custom order of elements (percent, ETA, bar) as well as leaving out elements
- Automatic ETA calculation
- Automatic window width calculation
Comments to this article
Leave a comment
Please note that your email address will not be shown, it is only used to fetch your avatar image from gravatar.com and for notifications.


Would be neat to be able to customize the marker in the bar. So instead of having:
[#####-----------------------------------------]
we could maybe use
|-----[]-------------------------------------------|
or
[------> ]
That's in fact a very nice idea. You could define "left-hand character", "marker character" and "right-hand character". I'm going to implemented this.