Vim xdebug Debugging php PHP remote Debugging

Source: Internet
Author: User
Tags php debugger
Xdebug Configuration

Xdebug Installation

Original address: http://xiaobin.net/201007/using-vim-and-xdebug-to-debug-php-code/

In principle, this kind of debugging method mainly relies on vim plug-in "remote PHP Debugger" to implement, the plug-in implements a DBGP server. When debugging, Xdebug will establish a connection with the server to communicate, receive debug commands from the server and return the debug results.

Installation and Configuration

Xdebug

Installation:

Ubuntu under direct apt-get install Php5-xdebug installation

To/usr/lib/php5/20090626+lfs can see xdebug.so can be copied to the address of the module you specify

Configuration: (php.ini file)

Load Xdebug Extension:

zend_extension=/ /xdebug.so # Copy to the directory for you

Configure Xdebug to turn on DBGP remote debugging

Xdebug.remote_enable=on
Xdebug.remote_handler=dbgp

Vim's Debugger Plugin

This simple, just need to download the plugin back, unzip and put into the ~/.vim/plugin directory

Debugging process

Use VIM to open the PHP file you want to debug, press to enter the debug state. Please step into the PHP debugging guide, which is written in more detail.

Precautions

In the actual process, if you find that the installation is still not working properly with PHP, it is most likely caused by the following reasons:

One, xdebug loading is not successful

You can confirm that the Xdebug was successfully loaded by phpinfo or "php-m". The reason for the unsuccessful loading may be that PHP is "Debug Build" (which can be confirmed by Phpinfo), so php.ini should not use "zend_extension=/ /xdebug.so" instead of "zend_ extension_debug=/ /xdebug.so ";

The other aspect is to pay attention to whether the xdebug.so path is correct, or if the Apache service or FASTCGI service is restarted.

The phpinfo display is displayed as follows, indicating normal

Second, the debugging session has expired

XDebug a cookie to determine if you are debugging a conversation, please note that this cookie expires in 1 hours. One day when you work in work, found Vim + xdebug just work, how do not work, it is mostly because this session has expired.

The debug session lasts 1 hours, as long as the parameter "Xdebug_session_start=1″" is appended to the URL.

Access path:

For-Clean URLs use:http://example.com/admin/feature?xdebug_session_start=1

Otherwise use:http://example.com?q=admin/feature&xdebug_session_start=1

Iv. Change the Debug wait time (default 5 seconds)

Edit debuger.py

2. Press and browse php file within 5 seconds. :-)
If you do setup correctly, server would make connection to vim.
[You can change the port by editing last line of Debugger.vim]

All the Windows currently opened would be closed and debugger interface would be shown.

3. In Debuggin mode
: Resizing windows
: Step into
: Step through
: Step out

: Stop Debugging

: Shows all variables
: Shows variable on current cursor

, e:evalute expression and display result. C Ursor is automatically move to watch window. Type line and just press ENTER.

Command line command)
: Bp:toggle breakpoint in Current line
: Up:goto Upper Lev El of Stack
:D N:goto lower level of the stack

4. Press to stop Deb Ugging.
Then, debugger windows would be closed and windows would be restored.
(holy:mksession feature)

Reference and extension reading Using vim and xdebug DBGP for debugging Drupal (or any PHP application) remote PHP Debugger

First download xdebug2.1.0, in the official homepage download source code, download back the file name is: xdebug-2.1.0.tgz
The version of Xdebug should correspond to your PHP version, because even PHP is 5.3.2, so download xdebug2.1.0

XML code

Cd/your/download/path tar zxvf xdebug-2.1.0.tgz cd xdebug-2.1.0

Run Phpize

XML code

Phpize

If you do not add phpize to $path, you should use the full path

There is no need to--prefix, compile and then directly modules in the xdebug.so files copied away.

XML code

./configure--enable-xdebug--with-php-config=/usr/local/php/bin/php-config

XML code

Make

Copy the xdebug.so to the PHP installation directory, install PHP when the installation directory was specified, so copy into the/usr/local/php/xdebug. You can copy anywhere you want, as long as you know well. You need to change the path of the following command to your own.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.