Ⅰ. 插件描述
veriy simple xdebug protocol implementation so that you can debug PHP easily with VimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'marcweber/vim-addon-xdebug'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'marcweber/vim-addon-xdebug'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'marcweber/vim-addon-xdebug'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/marcweber/vim-addon-xdebug
Ⅳ. 文档说明
No, this is no complete xdebug implementation and it will never be one.
This tries to be a quick and dirty hack to get some of my jobs done without
always firing up Eclipse
dependencies:
- see vim-addon-xdebug-addon-info.txt
- socat
http://url?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=12894211795611
HOWTO:
1) make sure vim-addon-async works (compile the c helper application)
2) :XDbgStart
3) open web page such as
http://url?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=12894211795611
4) call g:xdebug.ctx.send('step_into')
(Vim crashes soon :-( )
It seems to crash less often when switching syn off! ??
See plugin/xdebug.vim to see that Eclipse standard mappings have are used by
default.
XDbgStack works (current stack is feed to quickfix)
Eg this prints the contents of $_GET
call xdebug#Eval('$_GET')
5) watching vars:
manually: call xdebug#Eval('$_GET')
more convenient:
XDbgVarView opens a buffer. Add lines like this:
watch $_GET
watch $_POST['foo']
use :UpdateWatchView to update the buffer.
This will be done automatically on stepping.
You can visually select lines and press <cr> to execute arbitrary PHP code
6) breakpoints
XDbgBreakPoints opens a window. You add breakpoints by adding lines (the way shown below the marker)
then pressing enter. Some more porcelaine is missing!
As alterntavie press F9 or use the XDbgToggleLineBreakpoint command
:-) Most of the breakpoint types are not supported by xdebug?
" Add to your .vimrc to enable breakpoint on first line.
let g:xdebug = {'stop_on_first_line': 1}
7) xdebug port (defaults to 9000):
Either call fun! xdebug#Start({'port':9001})
or set it in your .vimrc:
let g:xdebug.opts = { 'port' : 9001 }
TODO:
Help me make this all more mature / complete
- inspect vars (stack level!)
- exec code
- break points
- encoding has been implemented in webapi-vim
- implement things like "goto cursor" (there is a temporary breakpoint command)
- ...
This is the protocol documentation I found:
- http://xdebug.org/docs-dbgp.php
- The messages sent by PDT (Eclipse) can be debugged easily.
Note
This plugin has enough features for everyday work now.
If you want more let me know.
Thanks TO
mattn (github) who wrote the nice XML parsing library which also contains the
bas64 enc/decoding
Screeshot:
see branch screenshots or visit this url:
http://mawercer.de/~marc/vim-xdebug-screenshot.png
related work
http://www.vim.org/scripts/script.php?script_id=4009
https://github.com/derickr/xdebug
Don't by shy and read this very accurate list about why PHP sucks:
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/