Hi list,
I've been working on a task to import a load of data from one site to
another (>1M records in some cases), I was getting pretty frustrated
that I couldn't track the progress very well, so I wrote an extension to
sfBaseTask, which I then use as the base class for any task needing a
progress bar. It works for me, so I thought I'd share it.
Here's the class: http://pastebin.com/HLEZqYY9
Steps to integrate:
1. Create your new task the usual way (symfony generate:task
[--dir="..."] [--use-database="..."] [--brief-description="..."] task_name)
2. Edit the new task definition, set it to extend mySfTask rather than
sfBaseTask
3. Use the progress bar as follows:
// Here's the loop I'd like to track the progress of:
for($i = 0; $i < 1000; $i++)
{
$this->progressBar($i,1000);
}
What the progress bar outputs:
- activity indicator (a single character that cycles through /, -, \
and | on each iteration)
- percentage progress
- a wget-style progress bar
e.g.:
- 50%
[================================>
]
This should be compatible with sf1.2 and above, but I've only tried it
with sf1.4 - YMMV.
Last thing - anyone know how I can auto-set the width of the progress
bar from the width of the terminal?
Thanks,
Ben
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en