windows环境配置xhgui监控thinkphp

环境说明

web环境phpEnv

php版本7.2

 thinkphp版本6.0.2

安装xhprof扩展

windows tideways-xhprof 扩展

  1. 选择对应版本扩展
  2. 解压至php/ext目录
  3. 配置php.ini增加引入扩展,重启服务生效

extension = tideways_xhprof.dll

安装xhgui中文版

xhgui中文版

git clone https://github.com/laynefyc/xhgui-branch xhgui-cn
cd xhgui-cn
php install.php
composer update

composer.phar下载比较慢,可以自己复制本地的composer.phar至 xhgui-cn目录,然后再执行php install.php

mongo连接配置

编辑config/config.default.php

// Needed for file save handler. Beware of file locking. You can adujst this file path
// to reduce locking problems (eg uniqid, time ...)
//'save.handler.filename' => __DIR__.'/../data/xhgui_'.date('Ymd').'.dat',
'db.host'              => 'mongodb://192.168.102.137:27017',
'db.db'                => 'xhprof',

// Allows you to pass additional options like replicaSet to MongoClient.
// 'username', 'password' and 'db' (where the user is added)
'db.options'           => array(
    'username' => '账号',
    'password' => '密码',
),

设置扩展为tideways_xhprof

    /*
     * support extension: uprofiler, tideways_xhprof, tideways, xhprof
     * default: xhprof
     */
    'extension'            => 'tideways_xhprof',

添加站点至xhgui-cn/webroot 

访问www.xhgui.com,看到如下界面说明xhgui部署完成

引入监控

  • 入口文件引入
  • // [ 应用入口文件 ]
    namespace think;
    
    require __DIR__ . '/../vendor/autoload.php';
    
    require 'd:/www/xhgui-cn/external/header.php';
    
    // 执行HTTP应用并响应
    $http = (new App())->http;
    
    $response = $http->run();
    
    $response->send();
    
    $http->end($response);

     

  • BaseController引入(推荐)
  •     /**
         * 构造方法
         * @access public
         * @param  App  $app  应用对象
         */
        public function __construct(App $app)
        {
            $this->app = $app;
            $xhprof    = 'd:/www/xhgui-cn/external/header.php';
            if ($this->app->isDebug() && file_exists($xhprof)) {
                require $xhprof;
            }
            $this->request = $this->app->request;
    
            // 控制器初始化
            $this->initialize();
        }

    在debug模式下启用监控

  • 访问被监控的站点后,再查看www.xhgui.com就可以看到监控的信息了

参考链接

https://blog.it2048.cn/article-tideways-xhgui/

https://blog.csdn.net/weixin_37281289/article/details/96591978?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-5.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-5.nonecase

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值