Vim+xdebug Debugging PHP

Source: Internet
Author: User
Vim+xdebug Debugging PHP

1. Install xdebug
sudo apt-get install php5-xdebug

2. Configure Xdebug
Edit/etc/php5/apache2/conf.d/ Xdebug.ini, join
xdebug.remote_enable = 1
Xdebug.remote_port = 9000
Xdebug.remote_host = localhost

3 Install the vim plugin dbgp
Download page: http://www.vim.org/scripts/script.php?script_id=1929
and put it in the plugins directory after download.

4. Open the PHP page you want to debug in the browser and add it after the URL? Xdebug_session_start=1 parameter
Use VIM to open this file, with: Bp set breakpoints, and then the F5 key, VI will prompt waiting for a new connection on port 9000 for 5 seconds ... , this time in 5 seconds to refresh the page just now, you can see the debugging interface in Vim.

If it appears, Attributeerror ("Dbgprotocol instance has no attribute ' stop ', then no configuration is successful, either xdebug.remote_* is not configured, or the URL Not joined at the tail? Xdebug_session_start=1, either you didn't refresh the page within 5 seconds.

5. When you get the contents of a variable, if the variable is an array, then the default will only show (array), instead of displaying the elements within the array, if the contents of the array elements cannot be displayed, then debugging will encounter a lot of problems, so you can according to the comments in the Debugger.vim, self- Add the following line to the. VIMRC:

Let g:debuggermaxdepth = 5
More configurations, which can be followed and so on, are described in Debugger.vim.

Go from http://lds2008.blogbus.com/logs/115127244.html

  • 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.