Windows + Vim + Xdebug

本文介绍如何配置Xdebug和Vim进行PHP调试。主要内容包括Xdebug的基本配置、Dbgp的下载与安装、Vim中debugger.py文件的修改、调试步骤及常见问题解决方法。
php.ini配置
[Xdebug_vim]
zend_extension_ts="c:\php\ext\php_xdebug-2.1.0-5.2-vc6.dll"
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_host = localhost
xdebug.trace_output_dir="E:\xdebug"
xdebug.profiler_output_dir="E:\xdebug"
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=off


下载安装Dbgp

下载后放入plugins目录中即可,是vim73下面的plugins,不是vimfiles下面的


修改debugger.py文件

node.getAttribute('filename')[7:] 改成 node.getAttribute('filename')[8:]

res.firstChild.getAttribute('fileuri')[7:] 改成 res.firstChild.getAttribute('fileuri')[8:]

'file':  s.getAttribute('filename')[7:] 改成 'file':  s.getAttribute('filename')[8:],


下载安装python,7.3对应的是python2.7

调试方式:
1、用浏览器打开你要调试的页面文件,并在url尾部加上如下形式: http://localhost/blog/index.php?XDEBUG_SESSION_START=1

2、用vim打开此文件,用可 :Bp 设置断点,然后安 F5 键, 你将会看见
waiting for a new connection on port 9000 for 5 seconds…
此时在5秒内刷新刚才那个页面,即可在vim中看到调试界面。

如果出现 <type 'exceptions.AttributeError'>, AttributeError("DbgProtocol instance has no attribute 'stop'", 则说明没有配置成功,要么是 xdebug.remote_* 没有配置好,要么是url尾部上没有加入 ?XDEBUG_SESSION_START=1 ,要么是你没有在5秒内刷新页面 .

" 配置Xdebug,显示内容
let g:debuggerMaxDepth = 5

如果在调试的时候出现乱码问题,在.vimrc中,设置

" 处理文本中显示乱码
set encoding=utf-8
set fileencodings=chinese
set fileencoding=chinese

" 处理菜单及右键菜单乱码
source $vimruntime/delmenu.vim
source $vimruntime/menu.vim

" 处理consle输出乱码
language messages zh_cn.utf-8

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值