Vim xdebug debug PHP Remote debugging

Source: Internet
Author: User
Tags php debugger
ArticleDirectory
    • Installation and configuration
    • Debugging process
    • Notes
    • Reference and extended reading

Xdebug Configuration

Xdebug Installation

 

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

In principle, this debugging method relies mainly on the vim plug-in "Remote PHP Debugger", which implements a dbgp server. During debugging, xdebug establishes a connection with the server, receives Debugging commands from the server, and returns the debugging result.

Installation and configuration

Xdebug

Installation:

Ubuntu directApt-Get install php5-xdebugInstall

To/Usr/lib/PhP5/20090626 + LFS You Can See That xdebug. So can be copied to your specified module address.

 

Configuration :(PHP. iniFile)

    • Load xdebug extension:

      Zend_extension =/<Extension_dir>/Xdebug. So# <Extension_dir> the directory you copied

    • Configure xdebug to enable dbgp remote debugging

      Xdebug. remote_enable = on
      Xdebug. remote_handler = dbgp

Vim debugger plug-in

This is simple. You only need to download the plug-in and decompress it ~ /. Vim/plugin directory

Debugging process

Use Vim to open the PHP file to be debugged and press<F5>Enter the debugging status. Please go to the PHP debugging guide, which describes in detail.

Notes

In the actual process, if you find that PHP debugging is still not working properly after the installation is complete, it may be caused by the following reasons:

I,Xdebug loading failed

You can use phpinfo or "PHP-M" to check whether xdebug is successfully loaded. The reason for loading failure may be that PHP is "Debug build" (which can be confirmed through phpinfo). Therefore, "zend_extension =/" should not be used in PHP. ini/<Extension_dir>/Xdebug. So, instead of zend_extension_ Debug=/<Extension_dir>/Xdebug. So ";

In other aspects, check whether the xdebug. So path is correct, and whether the apache service or FastCGI service is restarted.

Phpinfo is displayed as follows, indicating normal

II. The debugging session has expired.

Xdebug uses a cookie to determine whether you are debugging the conversation. Note that the cookie expires for one hour. One day when you work hard, you find that VIM + xdebug is still working. Why don't you do it again? Most of the reason is that this session has expired.

As long as the parameter"Xdebug_session_start = 1", The debugging session will last for 1 hour.

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

 

4. Change the debugging wait time (5 seconds by default)

 

Edit debuger. py

 

 

 2. Press <F5> and browse PHP file within 5 seconds .:-)
If you did setup correctly, server will make connection to vim.
[You can change port by editing last line of Debugger. Vim]

All the windows currently opened will be closed and debugger interface will be shown.

3. In debuggin Mode
<F1>: resizing windows
<F2>: Step
<F3>: Step over
<F4>: step out

<F6>: Stop debugging

<F11>: shows all variables
<F12>: shows variable on current cursor

, E: evalute expression and display result. cursor is automatically move to watch window. type line and just press Enter.

Command Line command)
: BP: toggle breakpoint on current line
: Up: goto upper level of stack
: DN: goto lower level of stack

4. Press <F6> to stop debugging.
Then, debugger windows will be closed and windows will be restored.
(Holy: mksession feature)

Reference and extended reading
    1. Using vim and xdebug dbgp for debugging Drupal (or any PHP application)
    2. Remote PHP Debugger

 

Download xdebug2.1.0 on the official homepage.Source code, The downloaded file is: xdebug-2.1.0.tgz
The xdebug version must correspond to your PHP version. Because PHP is 5.3.2, download xdebug2.1.0.

XML Code
    1. CD/Your/download/path
    2. Tar zxvf xdebug-2.1.0.tgz
    3. CD xdebug-2.1.0

 

Run phpize

XML Code
    1. Phpize

 

If phpize is not added to $ path, use the full path

 

-- Prefix is not required here. After compilation, copy the xdebug. So file in modules directly.

XML Code
    1. ./Configure -- enable-xdebug
    2. -- With-PHP-config=/Usr/local/PHP/bin/PHP-config

 

 

XML Code
    1. Make

 

 

Copy xdebug. So to the PHP installation directory, and specify the installation directory when installing PHP. Therefore, copy it to/usr/local/PHP/xdebug. You can copy everything you want, as long as you know... You need to change the path of the following command to your own.

Related Article

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.