PHPackages                             guangzhonghedd01/xhgui-collector - 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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. guangzhonghedd01/xhgui-collector

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

guangzhonghedd01/xhgui-collector
================================

Library for collecting and storing XHProf results for later use by XHGUI.

2.1.2(7y ago)88.6k1[1 issues](https://github.com/guangzhonghedd01/xhgui-collector/issues)MITPHPPHP &gt;=7.0.0

Since Sep 13Pushed 7y ago1 watchersCompare

[ Source](https://github.com/guangzhonghedd01/xhgui-collector)[ Packagist](https://packagist.org/packages/guangzhonghedd01/xhgui-collector)[ RSS](/packages/guangzhonghedd01-xhgui-collector/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (3)Dependencies (1)Versions (10)Used By (0)

XHGUI Collector - laravel5/thinkphp5
====================================

[](#xhgui-collector---laravel5thinkphp5)

fork from [xhgui-collector](https://github.com/perftools/xhgui-collector)

改造后支持 psr-4，框架可以一键对日志进行采集。

数据采集存储于mongodb,其它存储方式暂时没做测试。

展示可以使用：

- [xhgui](https://github.com/perftools/xhgui)
- [xhgui-branch](https://github.com/laynefyc/xhgui-branch)

使用指南
----

[](#使用指南)

- `composer require guangzhonghedd01/xhgui-collector`
- env 配置信息

```
XHGUI_MONGO_URI=127.0.0.1:27017
XHGUI_MONGO_DB=xhprof
XHGUI_PROFILING_RATIO=100
XHGUI_EXECUTE_SECOND=1
XHGUI_PROFILING=enabled
XHGUI_FILTER_VAR=XHGUI_FILTER_VAR
APP_NAME=test

```

envdescriptionexampledefaultXHGUI\_MONGO\_URImongodb 地址`XHGUI_MONGO_URI=mongo:27017`127.0.0.1:27017XHGUI\_MONGO\_DB库名`XHGUI_MONGO_DB=xhprof`xhprofXHGUI\_PROFILING\_RATIO采样比率`XHGUI_PROFILING_RATIO=50` 对50%请求进行采集`XHGUI_PROFILING_RATIO=100`XHGUI\_PROFILING采集开关`XHGUI_PROFILING=enabled`如果不填写值就是关闭状态XHGUI\_EXECUTE\_SECOND执行时间门槛(秒)`XHGUI_EXECUTE_SECOND=1`XHGUI\_EXECUTE\_SECOND=1 执行时间大于1秒才采集,支持小数,如:0.1XHGUI\_FILTER\_VAR需要过滤ENV的敏感数据信息`XHGUI_PROFILING=xx_password`没有默认值APP\_NAME项目名称`APP_NAME=test`test### Laravel

[](#laravel)

- 将Xhgui/config/laravel.php 拷贝到 laravel 项目config文件夹下，更名为xhgui.php
- 在需要采集的路由上增加中间件

```
class Xhprof extends Middleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure                 $next
     *
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        xhgui_laravel();

        return $next($request);
    }
}

```

### Thinkphp

[](#thinkphp)

- 将Xhgui/config/laravel.php 拷贝到项目application/extra/件夹下，更名为xhgui.php(extrea文件夹可能不存在)
- 增加/www/web/ydapi-dadi01-com/extend/hook目录下新增Xhgui.php,

```
