-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5e304ed
Showing
3 changed files
with
1,512 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
This is a mirror of http://www.vim.org/scripts/script.php?script_id=4059 | ||
|
||
This is a plugin to enable php debug in VIM with Xdebug, which originates from http://www.vim.org/scripts/script.php?script_id=1152. | ||
But most of the code, especially the debugger backend has been rewritten. | ||
|
||
Tested with -- | ||
* XDebug 2.2 - PHP 5.4 - GVIM 7.3 - Python 2.7 @ Windows 7 | ||
* XDebug 2.0 - PHP 5.2 - VIM 7.3 - Python 2.7@ Linux | ||
* XDebug 2.0 - PHP 5.2 - VIM 7.3 - Python 2.3@ Linux | ||
* XDebug 2.2 - PHP 5.2 - VIM 7.3 - Python 2.7@ Linux | ||
|
||
The source code is hosted at https://github.com/brookhong/DBGPavim. | ||
Some screenshots (under windows) are here at http://sharing-from-brook.16002.n6.nabble.com/Debug-php-in-VIM-with-Xdebug-and-DBGPavim-td4930670.html. | ||
|
||
## The enhancements are -- | ||
|
||
### Non blocking debugger backend. | ||
So that VIM users do not need to wait for connection from apache server. No timeout things, users press F5 to start debugger backend, and uses his/her VIM normally. Debug backend won't stop users to interact with VIM. Users can press F6 to stop debugger backend anytime. | ||
|
||
### Catch all connections from apache server. | ||
This is very important for a large website, especially for thoes pages who contain AJAX requests. In that case, one reload of a page may trigger dozens of http request, each of them goes to a different URL. The new debugger backend will catch all connections from apache server. Users can debug all of them without missing anyone. | ||
|
||
### Break only at breakpoints | ||
|
||
let g:debuggerBreakAtEntry = 0 | ||
|
||
The setting will cause debugger backend to break only at breakpoints. Default value is 1, which means it works like before, the debugger backend breaks at entry. | ||
|
||
### New commands and function keys | ||
|
||
In normal mode | ||
|
||
<F5> => start debugger backend | ||
<F6> => stop debugger backend | ||
<F8> => toggle debuggerBreakAtEntry, when g:debuggerBreakAtEntry=0, debugger backend breaks only at breakpoints. | ||
|
||
:Bl => to list all breakpoints | ||
:Bp => toggle breakpoint on current line | ||
|
||
In debuggin mode | ||
|
||
<F1> => toggle help window | ||
<F2> => step into | ||
<F3> => step over | ||
<F4> => step out | ||
<F5> => start debugging / run | ||
<F6> => stop debugging | ||
<F7> => evalute expression and display result. cursor is automatically move to watch window. type line and just press enter. | ||
<F9> => toggle layout | ||
<F11> => shows all variables | ||
<F12> => shows variable on current cursor | ||
|
||
:Pg => to print value of complex variables like $this->savings[3] | ||
:Up => goto upper level of stack | ||
:Dn => goto lower level of stack | ||
|
||
In Watch window | ||
|
||
If you press Enter key at a line which ends with -- | ||
|
||
(object) => to get value of an object. | ||
(array) => to get value of an array. | ||
|
||
If you press Enter key at a line of output from command :Bl, that breakpoint will be located. | ||
|
||
In Stack window | ||
|
||
If you press Enter key at a line, stack level will be set. | ||
|
||
### Windows Support | ||
|
||
### Status line for debugger backend | ||
|
||
After user press <F5> to start debugger backend, a string like "PHP-bae-LISN" will show up at the right side of status line. | ||
|
||
The status string looks like -- | ||
|
||
PHP-<bae|bap>-<LISN|PENDn|CONN|CLSD> | ||
|
||
bae => means Break At Entry | ||
bap => means Break only At breakPoints | ||
|
||
LISN => means the debugger backend is listening. | ||
PENDn => means there are n connections waiting for debugging. | ||
CONN => means debug session has been established, and being debugged. | ||
CLSD => means the debugger backend has stopped. | ||
|
||
### New layout of windows | ||
|
||
## Usage | ||
|
||
* Make sure your vim has python(at least 2.3) supported, in vim with command | ||
|
||
:version | ||
|
||
In case of your VIM don't support python, download VIM source package from http://www.vim.org/download.php, then build your own VIM with commands -- | ||
|
||
./configure --prefix=/opt/vim --enable-pythoninterp --with-python-config-dir=/usr/lib/python2.4/config | ||
make | ||
make install | ||
|
||
* Install xdebug for php, and edit php.ini | ||
|
||
zend_extension=path_to_xdebug.so | ||
xdebug.remote_enable=1 | ||
|
||
* Edit your ~/.vimrc | ||
|
||
let g:debuggerPort = 9009 | ||
let g:debuggerBreakAtEntry = 0 | ||
|
||
* Edit your apche configure file | ||
|
||
In your VirtualHost section, set debugger port same as the one in your vimrc | ||
|
||
php_value xdebug.remote_port 9009 | ||
|
||
* Save debugger.py and debugger.vim to your ~/.vim/plugin | ||
|
||
* Open your php file, use :Bp to set breakpoints | ||
|
||
* Now, press F5 to start debugger backend | ||
|
||
* Back to your browser, add XDEBUG_SESSION_START=1 to your URL, for example, http://localhost/index.php?XDEBUG_SESSION_START=1. If you would like to debug from CLI, start your php script like | ||
|
||
php -dxdebug.remote_autostart=1 -dxdebug.remote_port=9009 test.php | ||
|
||
If you are tied of adding XDEBUG_SESSION_START=1 in query string, there is a XDEBUG_SESSION helper at http://userscripts.org/scripts/review/132695, a user script for Google Chrome. It also works for Firefox with help of GreaseMonkey. | ||
|
Oops, something went wrong.