Xhprof 配置方法小结

  xhprof是一个分层php分析工具。

  

  一、Xhfrof的下载

  下载链接:https://pecl.php.net/package/xhprof

  

 

   分别下载2.2.3的tgz版和dll版。

 

  https://pecl.php.net/package/xhprof/2.2.3/windows  

  

 

   DLL版中,请注意线程安全与非线程安全2个版本的选择(非线程安全的PHP版本对应非线程安全的xhprof扩展)

 

  二、Xhprof的安装  

  

 

   将dll版中的php_xhprof.dll添加到php扩展目录文件夹下,例如 D:\phpstudy_pro\Extensions\php\php7.4.3nts\ext

  修改对应的php.ini文件,先确认extension_dir="D:\phpstudy_pro\Extensions\php\php7.4.3nts\ext"

  在php.ini中添加扩展信息:

extension=xhprof
[xhprof]
xhprof.output_dir=D:\phpstudy_pro\xhprofoutputdir

   其中xhprof.output_dir为xhprof结果文件写入路径

 

  重启web服务,访问phpinfo(),确认是否安装成功

  

 

 

 

  三、添加XHprof示例

  将tgz版中的examples,xhprof_html,xhprof_lib 三个文件夹复制到可访问web服务的同一文件夹下,例如

  

 

 

   并用浏览器访问examples文件夹下的sample.php文件

   

 

 

  同时在xhprof.output_dir对应的路径下会写入文件

   

 

  再使用sample.php页面如上图选中的index路径作为get参数

  “run=641021e0eeb88&source=xhprof_foo”,访问xhprof_html中的index.php即可,例如 http://localhost/xhprof/xhprof_html/index.php?run=641021e0eeb88&source=xhprof_foo

  

 

posted @ 2023-03-14 15:34  阿木工作室  阅读(157)  评论(0编辑  收藏  举报