PHP Vim Debugger: Configuring Apache
I am trying to install Vdebug to debug PHP in Vim. Unfortunately, when I press F5 this message appears after a few seconds
Waiting for a connection (Ctrl-C to cancel, this message will self-destruct in
20 seconds...)
No connection was madeWhat should I do?
I searched about this in Google, followed this tutorial and this one (and many others) but did not work.
I followed Vdebug instructions.
I do not know how to achieve this:
Edit your apache configure file
In your VirtualHost section, set debugger port same as the one in your vimrc:
php_value xdebug.remote_port **9009**The remote_port that has just been mentioned is different from what I have in xdebug.ini and vimrc. Please, see below.
Right now I have in /etc/php5/apache2/conf.d/xdebug.ini:
zend_extension=/usr/lib/php5/20121212/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir=/media/www/xdebugdataAnd in my vimrc
let g:vdebug_options = {}
let g:vdebug_options["port"] = 9000I installed Xdebug helper Chrome extension too. Using an IDE is not an option: I wish to use Vim.
11 Answer
I solved it and now Vdebug is working.
Enable xdebug in PHP Edit your php.ini file and add the following under the "Module Settings" section:
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
zend_extension=/path/to/my/xdebug.so
[debug]
; Remote settings
xdebug.remote_autostart=off
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
; General
xdebug.auto_trace=off
xdebug.collect_includes=on
xdebug.collect_params=off
xdebug.collect_return=off
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=
xdebug.show_local_vars=0
xdebug.show_mem_delta=0
xdebug.max_nesting_level=100
;xdebug.idekey=
; Trace options
xdebug.trace_format=0
xdebug.trace_output_dir=/tmp
xdebug.trace_options=0
xdebug.trace_output_name=crc32
; Profiling
xdebug.profiler_append=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=crc32Try it out
Everything should be ready to go now. Restart apache and run phpinfo() to see if any xdebug information comes up. If it doesn't, then the apache error_log + google are your friends.
Otherwise, you are ready to run the debugger inside vim.
Open a PHP script in VIM that you can access from your localhost
Open that same PHP script in your web browser
Add F5. You should see at the bottom of VIM like "waiting for a new connection on port 9000 for 10 seconds..."
Within the next 10 seconds, refresh the browser page with the ?XDEBUG_SESSION_START=1 on the end of the URL.
Go back to VIM and you're in the debugger in all its glory.
Don't forget: to switch between windows in VIM, press CTRL-w-w.
Source -it applies to Ubuntu though it refers to another linux distribution-
Hope this helps.