当前位置:首页 > PHP教程 > php环境安装 > 列表

windows wamp中配置安装xhprof步骤

发布:smiling 来源: PHP粉丝网  添加日期:2014-08-25 16:56:04 浏览: 评论:0 

1.下载在这里 http://dev.freshsite.pl/php-extensions/xhprof.html.

我使用的是wamp 2.2d 32位的,这里罗嗦一句,既然用windows的wamp了,就不要装64位了,毕竟都是开发环境,正式环境肯定是32位的,这里下载两个文件 XHProf 0.10.3 for PHP 5.3 vc9.zip xhprof_html.zip

2.安装,这步骤很简单,把XHProf 0.10.3 for PHP 5.3 vc9.zip里面的dll文件重命名为 php_xhprof.dll 放在php的ext目录下,然后在php.ini配置里面加入配置,不要忘记创建对应的文件夹,代码如下:

  1. [xhprof] 
  2. extension=php_xhprof.dll 
  3. ; directory used by default implementation of the iXHProfRuns 
  4. ; interface (namely, the XHProfRuns_Default class) for storing 
  5. ; XHProf runs. 
  6. xhprof.output_dir=”d:/wamp/logs/xhprof_log” 

重启你的wamp即可,看看phpinfo()里面有没有对应的文件.

3.使用:xhprof_html.zip 这个文件解压到你想测试的网站根目录就好了,现在网站一般使用的是框架,唯一入口这点最好了,直接在index.php里面写就好了,我用的是yaf框架,代码如下:

  1. xhprof_enable();//开始 
  2. require 'init.php'
  3. require 'conf/db.inc.php'
  4. $app = new Yaf_Application(BASE_PATH . "/conf/itxiangqin.ini"); 
  5. Yaf_Registry::set('config', Yaf_Application::app()->getConfig()); 
  6. $app->bootstrap()->run(); 
  7. $xhprof_data = xhprof_disable();//结束,然后写入文件,注意目录 
  8. $XHPROF_ROOT = realpath(dirname(__FILE__).'/xhprof'); 
  9. include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php"
  10. include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php"
  11. //开源代码phpfensi.com 
  12. // save raw data for this profiler run using default 
  13. // implementation of iXHProfRuns. 
  14. $xhprof_runs = new XHProfRuns_Default(); 
  15.  
  16. // save the run under a namespace "xhprof_foo" 
  17. $run_id = $xhprof_runs->save_run($xhprof_data"xhprof_foo"); 
  18. echo "<a href='http://www.pztai.com/xhprof/xhprof_html/?run=$run_id&source=xhprof_foo'>分析</a>";// 

这里的pztai换成你自己的域名就好了,本地就localhost分析</a>";//这里的pztai换成你自己的域名就好了,本地就localhost.

Tags: wamp配置安装 xhprof配置安装

分享到: