定制 jepster/loop-tracker 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jepster/loop-tracker

Composer 安装命令:

composer require jepster/loop-tracker

包简介

A simple PHP class for tracking the status of a loop.

README 文档

README

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.

LoopTracker allows you to track the progress via a very handy call:

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".

So if you process 20 items per iteration, use the following line:

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):

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.

Afterwards you get informative messages into your console output as such:

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
----------------------

Getting Started

LoopTracker can be installed with Composer or downloaded manually.

With Composer

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.

{
	"require": {
		"jepster/loop-tracker": "dev-master"
	}
}

Manually

If you aren't using Composer, you just need to include lib/LoopTracker.php in your script.

require_once("path/to/LoopTracker.php");

Testing via PHPUnit

You need PHPUnit installed to run the tests. Configuration is defined in phpunit.xml.dist. Running the tests is easy:

phpunit

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL
  • 更新时间: 2015-06-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固