Skip to content

Commit

Permalink
Version 1.01
Browse files Browse the repository at this point in the history
1. remote debugging support
2. doc embeded
3. rename all global parameters from g:debuggerXXXX to g:dbgPavimXXXX
  • Loading branch information
brookhong authored and vim-scripts committed May 20, 2012
1 parent 5e304ed commit facb84c
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 104 deletions.
19 changes: 15 additions & 4 deletions README
@@ -1,5 +1,6 @@
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.

Expand All @@ -22,7 +23,7 @@ This is very important for a large website, especially for thoes pages who conta

### Break only at breakpoints

let g:debuggerBreakAtEntry = 0
let g:dbgPavimBreakAtEntry = 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.

Expand All @@ -32,7 +33,7 @@ In normal mode

<F5> => start debugger backend
<F6> => stop debugger backend
<F8> => toggle debuggerBreakAtEntry, when g:debuggerBreakAtEntry=0, debugger backend breaks only at breakpoints.
<F8> => toggle dbgPavimBreakAtEntry, when g:dbgPavimBreakAtEntry=0, debugger backend breaks only at breakpoints.

:Bl => to list all breakpoints
:Bp => toggle breakpoint on current line
Expand Down Expand Up @@ -87,6 +88,16 @@ In Stack window

### New layout of windows

### Remote debugging

In case that you need run VIM on a different machine from server where apache httpd runs, configuration for DBGPavim --

let g:dbgPavimPathMap = [['D:/works/php','/var/www'],]

Some change for Apache configuration is also necessary --

php_value xdebug.remote_host <ip_address_where_you_run_vim>

## Usage

* Make sure your vim has python(at least 2.3) supported, in vim with command
Expand All @@ -106,8 +117,8 @@ In Stack window

* Edit your ~/.vimrc

let g:debuggerPort = 9009
let g:debuggerBreakAtEntry = 0
let g:dbgPavimPort = 9009
let g:dbgPavimBreakAtEntry = 0

* Edit your apche configure file

Expand Down
137 changes: 137 additions & 0 deletions doc/dbgpavim.txt
@@ -0,0 +1,137 @@
*DBGPavim* 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

Some screenshots (under Windows 7) 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:dbgPavimBreakAtEntry = 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 dbgPavimBreakAtEntry, when g:dbgPavimBreakAtEntry=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

### Remote debugging

In case that you need run VIM on a different machine from server where apache httpd runs, configuration for DBGPavim --

let g:dbgPavimPathMap = [['D:/works/php','/var/www'],]

Some change for Apache configuration is also necessary --

php_value xdebug.remote_host <ip_address_where_you_run_vim>

## *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:dbgPavimPort = 9009
let g:dbgPavimBreakAtEntry = 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 dbgpavim.py and dbgpavim.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.

For more instructions, latest version and bug reports, please go to https://github.com/brookhong/DBGPavim.
4 changes: 4 additions & 0 deletions doc/tags
@@ -0,0 +1,4 @@
dbgpavim dbgpavim.txt /*DBGPavim*
dbgpavim-commands dbgpavim.txt /*commands*
dbgpavim-status dbgpavim.txt /*Status*
dbgpavim-usage dbgpavim.txt /*Usage*

0 comments on commit facb84c

Please sign in to comment.