以PHP5.2.8,Windows平台为例(其它PHP版本,其它平台请参看官网文档):
1. 在http://www.xdebug.org/download.php下载适合自己php版本的dll文件s
2. 将下载的xdebug.dll放到php/ext目录里,可以重命名也可以不重命名,这里我没有重命名。
3. 编辑php.ini,加入下面几行:
extension=php_xdebug-2.0.1-5.1.2.dll
;xdebug配置
[Xdebug]
;开启自动跟踪
xdebug.auto_trace = On
;开启异常跟踪
xdebug.show_exception_trace = On
;开启远程调试自动启动
xdebug.remote_autostart = On
;开启远程调试
xdebug.remote_enable = On
;收集变量
xdebug.collect_vars = On
;收集返回值
xdebug.collect_return = On
;收集参数
xdebug.collect_params = On
xdebug.profiler_enable=on
xdebug.trace_output_dir="D:/php/xdebug"
xdebug.profiler_output_dir="D:/php/xdebug" //(用来存放性能分析文件,可自由定义目录)
重启Apache;
写一个test.php,内容为<?php phpinfo(); ?>,如果输出的内容中有看到xdebug,说明安装配置成功。
xdebug support | enabled |
---|---|
Version | 2.0.2-dev |
xdebug+WinCacheGrind【有附件提供下载】将能更好的分析代码,启动WinCacheGrind,然后在 tools---options里设置working folder为刚才xdebug中指定的分析文件目录:D:/php/xdebug即可。
上面的步骤中容易出现的错误!
1.[03-May-2011 13:51:51] PHP Warning: PHP Startup: Unable to load dynamic library 'd:/wamp/bin/php/php5.2.8/ext/php_xdebug.dll' - 找不到指定的模块。
解决办法:出现该问题可能是xdebug和当前的php版本不匹配照成的,请换一个dll文件!
2.Debugger compile handler overriden, cannot continue
解决办法:删除php.ini中的该行
;zend_debugger.expose_remotely=allowed_hosts
下载http://sourceforge.net/projects/wincachegrind/ 即可,打开一个php页面就会再钢材定义的错误日志文件中找到他们,只要打开他们即可