PHP-5.5.x + Xdebug + Zend Studio 调试环境设置

参考:http://yulans.cn/zend-studio/%E3%80%90%E5%8E%9F%E5%88%9B%E3%80%91php-5-5-x-xdebug-zend-studio-%E8%B0%83%E8%AF%95%E7%8E%AF%E5%A2%83%E8%AE%BE%E7%BD%AE


为什么不用zend debugger,反而舍本求末用个偏方呢?因zend debugger目前最高只支持到php-5.3.x,php-5.4.x和php-5.5.x搞不定,所以需要xdebug,它就一备胎。

1、下载安装xdebug


1.1 到http://xdebug.org/download.php 下载适合你的PHP版本的xdebug


怎么找到适合的版本?

有四个信息需要匹配:

    1, PHP的版本,启动wamp后登陆http://localhost/?phpinfo=1查看PHP Version。比如我这里是:PHP Version 5.4.16

    2, Compiler,启动wamp后登陆http://localhost/?phpinfo=1查看Compiler。比如我这里是:MSVC9 (Visual C++ 2008)

    3, Architecture,启动wamp后登陆http://localhost/?phpinfo=1查看Architecture。比如我这里是:x86

    4, Thread Safety,启动wamp后登陆http://localhost/?phpinfo=1查看Thread Safety。比如我这里是:enabled

    根据上面四点,我们知道需要下载 PHP 5.4 VC9 TS (32 bit)

如果版本不匹配,会出现计算机中丢失php5.dll错误

参考:http://hi.baidu.com/tirestay/item/c2d0b106929f3819ebfe38e4



1.2 复制到php安装目录的ext文件夹,改名为php_xdebug.dll


php安装目录,我用的是wamp ,所以是D:\wamp\bin\php\php5.4.16\zend_ext

如果出现xdebug but it is installed错误,需要检查配置的php.ini文件是否正确,还要检查zend_extension路径是否正确

http://stackoverflow.com/questions/16236845/phpstorm-does-not-see-xdebug-but-it-is-installed


1.3 配置xdebug


在php.ini尾部添加如下

zend_extension = "D:\wamp\bin\php\php5.4.16\zend_ext\php_xdebug.dll"

[xdebug]
xdebug.auto_trace=1
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.trace_output_dir="D:/temp/xdebug"
xdebug.profiler_enable=1
xdebug.profiler_output_dir="D:/temp/xdebug" 
xdebug.profiler_enable=On 
xdebug.profiler_enable_trigger=1 
xdebug.default_enable=On 
xdebug.show_exception_trace=On 
xdebug.show_local_vars=1 
xdebug.max_nesting_level=50 
xdebug.var_display_max_depth=6 
xdebug.dump_once=On 
xdebug.dump_globals=On 
xdebug.dump_undefined=On 
xdebug.dump.REQUEST=* 
xdebug.dump.SERVER=REQUEST_METHOD,REQUEST_URI,HTTP_USER_AGENT 
xdebug.profiler_append = 1
xdebug.profiler_enable_trigger = 1
xdebug.remote_enable= 1  
xdebug.remote_autostart = 1   
xdebug.remote_host=10.1.11.120
xdebug.remote_port=9000 
xdebug.remote_handler = "dbgp"


端口号最好用默认的,也就是9000

xdebug.remote.host不能用localhost,应该用自己的ip


运行phpinfo();看有xdebug模块信息出来就是搞定了。


2、配置Zend Studio 支持xdebug


这里的配置很重要
选择Zend Studio 的 Window 》 Preference 》 PHP 》Installed Debuggers 双击 Xdebug,弹出对话框如下图

Debug Port 设为跟php.ini中设置的一样(默认是9000)。
Accept remote session(JIT) 选择localhost
允许浏览器访问网站时zend studio自动打开文件开始调试。


选项说明:
off: 关闭浏览器访问时打开调试功能;
localhost: 通过localhost访问网页的时候打开调试。
any:只要访问服务器上的php都打开调试;
prompt:访问服务器上的php时弹出询问是否要调试。

一旦打开zend studio允许xebug调试,所有访问php页面都会进入调试。
我们可以使用easy xdebug火狐插件可在客户端控制是否开启调试。


1、首先php.ini设置


xdebug.remote_autostart = 0
不自动启动调试。


2、安装火狐插件easy xdebug


安装好该插件后,点击如下图右下角小绿虫后,虫子上面有个小红点,这时候我们访问测试服务器的时候,Zend Studio就回自动弹出调试。


另外,可设置使用xdebug,在zend studio中对直接调试php文档,这里就不多说了。


1.4 使用WinCacheGrind配合XDebug分析PHP程序性能


在php.ini末尾添加xdebug.profiler_output_name = "cachegrind.out.%p"

http://www.nowamagic.net/librarys/veda/detail/2338


1.5 如果遇到launching waiting for xdebug session 57%这样的错误


把xdebug.remote_enable= 1 改成xdebug.remote_enable= on就行了

http://stackoverflow.com/questions/9534302/waiting-for-the-xdebug-session-57-in-eclipse-pdt


1.6 zend studio使用外部浏览器调试


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值