https://github.com/joonty/vdebug
SELinux does not allow httpd to connect to other network resources by default. Turn it on:
# setsebool -P httpd_can_network_connect 1
# getsebool -a | grep httpd_can
or
# chcon -v -t httpd_sys_content_t /usr/lib64/php/modules/xdebug.so
Note: http://stackoverflow.com/questions/2207489/apache-not-loading-xdebug-but-does-when-started-from-the-command-line
Edit ~/.vimrc:
# vim ~/.vimrc
let g:vdebug_options = {}
let g:vdebug_options["port"] = 9009
Edit xdebug configuration:
# vim /etc/php.d/15-xdebug.ini
; Enable xdebug extension module
zend_extension=xdebug.so
;zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9009
xdebug.remote_log=/tmp/xdebug.log
xdebug.remote_connect_back=0
xdebug.remote_autostart=0
xdebug.remote_mode=req
xdebug.max_nesting_level=1000
Sample script:
# vim test.php
<?php
here();
function here() {
xdebug_break();
echo name('Jun');
}
function name($name) {
$name .= '1';
return 'Hello ' . $name . ' ' . date('Y-m-d H:i:s');
}
Once in debugging mode, the following default mappings are available:
<F5>: start/run (to next breakpoint/end of script)
<F2>: step over
<F3>: step into
<F4>: step out
<F6>: stop debugging (kills script)
<F7>: detach script from debugger
<F9>: run to cursor
<F10>: toggle line breakpoint
<F11>: show context variables (e.g. after "eval")
<F12>: evaluate variable under cursor
:Breakpoint <type> <args>: set a breakpoint of any type (see :help VdebugBreakpoints)
:VdebugEval <code>: evaluate some code and display the result
<Leader>e: evaluate the expression under visual highlight and display the result
To stop debugging, press <F6>. Press it again to close the debugger interface.
If you can't get a connection, then chances are you need to spend a bit of time setting up your environment. Type :help Vdebug for more information.
Browser:
http://dru8.local/hello?XDEBUG_SESSION_START=1
Note: Append XDEBUG_SESSION_START=1 to the end of the URL.
No comments:
Post a Comment