Use xdebug to debug PHP programs in vim

Source: Internet
Author: User
Tags drupal

The operating system is centos 5.3, PHP 5.1.6, and xdebug 2.0.5.
References:
Xdebug installation documentation: http://xdebug.org/docs/install.
Xdebug remote debugging Configuration documentation: http://xdebug.org/docs/remote
Using vim and xdebug dbgp for debugging Drupal (or any PHP application ):

Http://2bits.com/articles/using-vim-and-xdebug-dbgp-for-debugging-drupal-or-any-php-application.html

Blog by a netizen:

Http://blog.johnpupu.tw/2008/05/14/208/

Required software package:
Vim plug-in ,:

Http://www.vim.org/scripts/script.php? Script_id = 1, 1929

Xdebug2.0.5 ,:

Http://xdebug.org/download.php

You also need to install Python or later.

First install xdebug:

Download the xdebug 2.0.5 source code package, decompress it, and go to the xdebug source code directory. Install the package according to the README file or the instructions in the xdebug installation documentation provided above. The phpize script is used. After PHP-devel is installed, the phpize and PHP-config scripts are installed.
[Root @ jcwkyl xdebug-2.0.5] # Mount/dev/CDROM
[Root @ jcwkyl xdebug-2.0.5] # localyum install PHP-devel
[Root @ jcwkyl xdebug-2.0.5] # phpize
Processing ing:
Php api version: 20041225
Zend module api no: 20050922
Zend extension api no: 220051025
[Root @ jcwkyl xdebug-2.0.5] #./configure-enable-xdebug
[Root @ jcwkyl xdebug-2.0.5] # Make
After completion, the xdebug. So file is generated in the modules directory.
[Root @ jcwkyl xdebug-2.0.5] # locate PHP. ini
/Etc/PHP. ini
[Root @ jcwkyl xdebug-2.0.5] # Vim/etc/PHP. ini
Add this sentence at the end of the file:
Zend_extension = "/home/WHB/lib/xdebug-2.0.5/modules/xdebug. So"
[Root @ jcwkyl xdebug-2.0.5] # service httpd restart
Verify that xdebug has been successfully installed:
[Root @ jcwkyl xdebug-2.0.5] # PHP-m
[PHP Modules]
Bz2
Calendar
......
Xdebug
......
Zlib
 
[Zend Modules]
Xdebug
Xdebug appears twice. One is in [PHP Modules] and the other is in [Zend Modules]. This indicates that it has been successfully installed.

Install the vim plug-in and copy the decompressed plugin/debug * to the/usr/share/vim/vim70/plugin directory.

Configure remote debugging for xdebug:
Add the following settings to/etc/php. ini:
Xdebug. remote_enable = 1
Xdebug. remote_host = "localhost"
Xdebug. remote_port = 9000
For more information, see the xdebug remote debugging settings document above.

Start vim, open the script to be debugged, and press F5. The following information is displayed:
Waiting for a new connection on port 9000 for 5 seconds...
Open the browser and enter the URL of the script to be debugged with parameters, such:

Http: // localhost/hello/index. php? XDEBUG_SESSION_START = 1

This action must be completed within five seconds. Then Vim will start debugging, the screen is as follows: http://hi.csdn.net/space-44778-do-album-picid-441760.html

 

For more information, see the shortcut keys defined in the Debug. Vim file.

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.