dev-master
9999999-dev https://github.com/jepster/LoopTrackerA simple PHP class for tracking the status of a loop.
LGPL
The Requires
- php >=5.3.0
tracking loop-tracker
Wallogit.com
2017 © Pedro Peláez
A simple PHP class for tracking the status of a loop.
A simple PHP class to output the status of a loop into the standard out via the "echo"-function. The functionality is tested by PHPUnit., (*1)
LoopTracker allows you to track the progress via a very handy call:, (*2)
LoopTracker::track('My loop title', count($total_items_to_iterate));
There's also a third parameter to pass, which sets the numbers of items which will be processed by one iteration. Default is "1"., (*3)
So if you process 20 items per iteration, use the following line:, (*4)
LoopTracker::track('My loop title', count($total_items_to_iterate), 20);
The full code of the loop looks like so (copied from the PHPUnit testing):, (*5)
for ($i = 0; $i <= 100; ++$i) {
LoopTracker::track('One Item per Iteration Loop Tracker PHPUnit Test', 100);
}
Of course you can do different things in your loop, than just track the loop., (*6)
Afterwards you get informative messages into your console output as such:, (*7)
Processing "One Item per Iteration Loop Tracker PHPUnit Test" 1 of 100 / 1% / elapsed seconds: 0 Processing "One Item per Iteration Loop Tracker PHPUnit Test" 2 of 100 / 2% / elapsed seconds: 0 ... Processing "One Item per Iteration Loop Tracker PHPUnit Test" 99 of 100 / 99% / elapsed seconds: 0 Processing "One Item per Iteration Loop Tracker PHPUnit Test" 100 of 100 / 100% / elapsed seconds: 0 ---------------------- Finish at: 16:45:15 - 28.06.15 Start was: 16:45:15 - 28.06.15 ----------------------
LoopTracker can be installed with Composer or downloaded manually., (*8)
If you're already using Composer, just add jepster/loop-tracker to your composer.json file.
LoopTracker works with Composer's autoloader out of the bat., (*9)
{
"require": {
"jepster/loop-tracker": "dev-master"
}
}
If you aren't using Composer, you just need to include lib/LoopTracker.php in your script., (*10)
require_once("path/to/LoopTracker.php");
You need PHPUnit installed to run the tests. Configuration is defined in phpunit.xml.dist. Running the tests is easy:, (*11)
phpunit
A simple PHP class for tracking the status of a loop.
LGPL
tracking loop-tracker