PHPackages                             apeipo/xl-util - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. apeipo/xl-util

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

apeipo/xl-util
==============

apeipo's util

1.0.11(8y ago)026MITPHPPHP &gt;=5.6.4

Since Jul 10Pushed 8y ago1 watchersCompare

[ Source](https://github.com/apeipo/XLUtil)[ Packagist](https://packagist.org/packages/apeipo/xl-util)[ RSS](/packages/apeipo-xl-util/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (8)Used By (0)

XLUtil
======

[](#xlutil)

XLCost
------

[](#xlcost)

耗时计算封装，使用：

```
XLCost::begin("costA");
usleep(100 * 1000); //100ms
XLCost::end("costA");

XLCost::begin("costB");
usleep(200 * 1000); //100ms
XLCost::end("costB");

#数组返回
print_r(XLCost::all());

#str返回
print(XLCost::str() . "\n");

# 循环中的耗时计算, 超过一次的项会计算平均耗时
//test repeat
for($i = 0; $i < 5; $i++) {
	XLCost::begin("costRepeat");
	usleep(50 * 1000);

	XLCost::begin("costInRepeat");
	usleep(80 * 1000);
	XLCost::end("costInRepeat");
	XLCost::end("costRepeat");
}
print_r("Test Repeat\n");
print_r(XLCost::flush());
```

XLLog
-----

[](#xllog)

针对Monolog的包装类

1. addNoticeKV, 只往日志里加notice的key但是不打印, 请求结束时一起打印。
2. logid, 可以在web请求的入口给日志设置logid，后续打印的日志均带有该logid。

使用：

```
use XLUtil\XLLog;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$handler = (new StreamHandler("./test.log", Logger::DEBUG));
$logger  = new Logger('test', [$handler]);

XLLog::setLogger($logger);
#设置全局logid， 这个逻辑可以放在web框架的入口，生成logid的方式请自行修改
XLLog::setLogid("LOG_ID", time());

XLLog::addNoticeKV("file", __FILE__); #增加key，但是不打印
XLLog::addNoticeKV("method", "test");
XLLog::warning("This is in test");
XLLog::flush("RequestFinish");  #打印所有的kv并清空

####output
[2017-07-10 13:22:56] test.WARNING: This is in test {"LOG_ID":1499692976} []
[2017-07-10 13:22:56] test.NOTICE: RequestDone {"file":"testMonologDecorator.php","method":"test","LOG_ID":1499692976} []
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity63

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

7

Last Release

3195d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef3c19f5e5e6814c81d06151e22605501a5798c55f95d727d5de75365847a879?d=identicon)[apeipo](/maintainers/apeipo)

---

Tags

logphpcostlog-decorator

### Embed Badge

![Health badge](/badges/apeipo-xl-util/health.svg)

```
[![Health](https://phpackages.com/badges/apeipo-xl-util/health.svg)](https://phpackages.com/packages/apeipo-xl-util)
```

###  Alternatives

[obs/esdk-obs-php

OBS PHP SDK

58121.1k3](/packages/obs-esdk-obs-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
