使用xdebug+eclipse远程调试centOS7上的PHP代码

这两天一直在研究PHP代码的调试,原来开发一直用的var_dump,麻烦!php

最近发现能使用xdebug+eclipse远程单步调试PHP,可是百度后实现此技术的文章都写得不够具体。chrome

我照着这里零散的文章弄了2天,弄好了,把完整的过程整理一份,方便查阅。apache

 

1.首先安装xdebug,去http://xdebug.org/wizard.php将你的phpinfo()复制进去,按照提示安装。windows

  安装完之后去配置php.ini加上下面几句话:浏览器

[xdebug]
xdebug.remote_enable = 1
xdebug.remote_host = 10.2.1.197
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
xdebug.remote_autostart = Off
zend_extension = /usr/lib64/php/modules/xdebug.so

 完成之后重启apache。eclipse

  (1)phpize 若是提示 “Can't find PHP headers in /usr/include/phpui

              The php-devel package is required for use of this command.this

     那么说明php-devel没有安装。spa

     输入yum install php-devel 安装就行了。debug

 

2.安装pdt eclipse,去http://www.eclipse.org/pdt/#download按提示下载安装

3.在Eclipse中配置Xdebug调试,首先菜单Window->Preferences->PHP->Debug->Installed Debuggers->XDebug ,如图

  

4.设置Eclipse中默认的调试浏览器,设成chrome

5.Chrome谷歌浏览器安装xdebug扩展程序" xdebug helper ",安好之后在扩展程序里设置一下

将扩展程序设成eclipse。

5.添加代码,将服务端php代码copy一份放到windows上来(用samba弄个远程镜像更好,省得拷来拷去的浪费时间),而后在eclipse里添加工程

6.用chrome访问服务端页面,下面图中点击debug

 而后刷新页面,会自动跳到eclipse里面,开始调试吧:)

相关文章
相关标签/搜索