How to debug PHP programs using NetBeans + xdebug _php Tutorial

Source: Internet
Author: User
Tags netbeans
According to the information on the network configuration debugging environment after the actual trial of the discovery function is relatively simple, single file debugging can also, if the cross-file debugging project is not so comfortable, the trial process because DBGP plug-ins also exist many defects, trouble constantly, often stack overflow, it is regrettable. Later think of np++ just editor, do not impose too much on it, plug-in version is also relatively low, there are many bugs can be understood, and so it slowly improve it, the power of the open source community is very powerful, ^^.
Last night in the altar a comrade's it again see NetBeans this familiar word (before the development environment because NB is very powerful, the function set is very humane, the interface is very friendly, and there is a very strong auto-complete function, are almost set it, but because at that time did not understand Xdebug, So do not understand how to debug, continue to use the EP Ctrl+b "Debug" program, with the "Xdebug" Google to find the NB debugging function is through its implementation, and full-featured, good evaluation, haha, big surprise, because too late to affect the rest of the roommate, Decide on the next day to fix it.
Today, after a stroll back, the development environment toss, now the configuration process is organized as follows:

[My environment]

Os:vista Business SP1 en_US
netbeans:6.5.1 PHP〈=zh_cn&option=php&version=6.5.1

[Install Xdebug]

1. Unzip the Php_xdebug-2.0.4-5.2.8.dll to the Ext folder in the PHP installation directory.
This machine is: D:\Wamp\php\ext
2, modify the php.ini, in the bottom add the following content:
Zend_extension_ts= "D:\Wamp\php\ext\php_xdebug-2.0.2-5.2.5.dll"
Note: The value of Zend_extension_ts is subject to your actual installation location, Xdebug will conflict with Zend_optimizer, please comment/delete zend_optimizer related statements in php.ini; xdebug.remote_ The value of port is the same as what is written in the debugger port of NB, options, the default is 9000
3, in the Vista environment, the way to load PHP via the Apache module after loading xdebug PHP script Apache will crash, if you want to use Xdebug debugging PHP program, you need to change the way PHP run to CGI, Please add the following in httpd.conf:
#LoadModule Php5_module D:/wamp/php/php5apache2_2.dll
#PHPIniDir "d:/wamp/php/"

Order Allow,deny
Allow from all

#AddType application/x-httpd-php. php
AddType application/x-httpd-php. php
Action application/x-httpd-php "/php/php-cgi.exe"

Note: Comments out are the configuration statements that load PHP in a modular way

[Start Debugging]

1. New and Open Project
2. Open the file you want to debug and set breakpoints.
3. Execute Debug "xxx.php" in the top menu and select "Server-side PHP" In the popup dialog box. When you click OK, NB will automatically open the file you want to debug using your default browser, such as: Http://localhost/Comsenz/UCenter_Home/index.php?XDEBUG_SESSION_START=netbeans-xdebug. At this point, you will find that the browser request has not returned, and NB in the lower right corner shows "Netbeans-xdebug is running", you can press F7 normal debugging program.
If a breakpoint is not set, the program will automatically pause execution on the first line of the current file when debugging. If you do not want to automatically pause the execution, uncheck the option->php-> on the first line to stop.
4, the form processing debugging can perform debugging and debugging projects, follow-up operations similar, but if you execute to the breakpoint you set the script, NB will automatically break at the breakpoint, waiting for you to debug ha!
5, in detail, please refer to NB Official commissioning guide

[Reference site] (NetBeans download) (xdebug download)


[ this post was last edited by Zwws on 2009-3-29 02:55]

1. Open the project and set breakpoints. jpg

2, the implementation of debugging. jpg

3, debugging mode. jpg

4, single-step debugging. jpg

5. Project Commissioning (cross-page). jpg

Little Z is always so detailed in writing things. Top!
PS: Lou Zhu's head is very thunder 1. " Xdebug will conflict with Zend_optimizer, please comment/delete the Zend_optimizer-related statements in php.ini "
Do not know which statements are related to the Zend_optimizer statement landlord can give detailed
2. My is the win operating system
PHP 5.2.9
Apache 2.11

Do not know whether and the landlord configuration is the same way
3. I also like the development model of NetBeans, but Xdebug is always good at debugging. I did it many times online.
It's still not working. The final choice to give up to see the landlord published specific configuration method is very grateful, but there are
Two questions I hope to get the landlord's fastest and most detailed reply to the answer very much thank sejie10011 (2009-3-31 11:07:11) the landlord wrote so detailed. Top! ZWWS (2009-3-31-12:22:52) 1, hehe, the way to solve the problem is very important, if you know how Zend_optimizer is installed, that does not solve the problem?
I used "Zend_optimizer php.ini" in Google to search this article
So you just have to follow the article in the local php.ini found in the article mentioned in the relevant statement comments out of the good, is actually "zend_optimizer." The beginning of the statement. Of course, if you install the Zend_optimizer.

2, Xdebug 2.0.4 support PHP 5.2.9. ZWWS (2009-3-31 12:24:14) bean sauce. Niohe (2009-3-31-22:43:54) Thanks LZ for advice!! Iminto (2009-4-02-19:58:07) support landlord Gross (2009-4-03 17:02:32) Zend Optimizer and Xdebug can coexist Qgymje (2009-8-27 11:56:53) I'd like to ask about my situation.
Step out after commissioning can not be used Zhenjiangdeni (2010-6-23-14:42:03) landlord, I have to follow your configuration, why, the IDE and the lower corner is always showing waiting for the connection (NETBEANS-XDEBUG). There is no way to debug Luzhou ( 2010-6-25 19:29:22) Good! Luzhou (2010-6-25 19:31:05) Http:// (2010-6-25-20:58:24) reply 12# zhenjiangdeni true techarticle according to the information on the network configuration debugging environment after the actual trial of the discovery function is relatively simple, single file debugging can also, if the cross-file debugging project is not so comfortable, the trial process ...

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