How to debug PHP programs using NetBeans + xdebug _php Tips

Source: Internet
Author: User
Tags php script netbeans
According to the data on the network configuration of debugging environment after the actual trial of the discovery function is relatively simple, single file debugging can also, if it is a cross file debugging project is not so comfortable, the trial process because the DBGP plug-ins also exist many defects, constantly worry, regular 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 are also understandable, and so it slowly perfect again, the power of open source community is very powerful, ^^.
In the altar last night, a comrade's Bovenri again saw the familiar word of NetBeans (when the development environment was chosen because NB was very powerful, the function setting is very human, the interface is very friendly, and has the very strong automatic completion function, all almost must decide it, but because at that time did not understand has the xdebug, So I don't know how to debug, continue to use the EP Ctrl+b "Debug" program, and add "Xdebug" Google a bit to find the function of NB debugging is achieved, and full-featured, evaluation is good, haha, big surprise, because too late afraid to affect the rest of the roommate, I decided to take it up the next day.
......
Today, after a stroll back, the development environment to toss a few, the configuration process is sorted as follows:

[My environment]

Os:vista Business SP1 en_US
php:5.2.8
apache:2.2.11
netbeans:6.5.1 PHP
http://www.netbeans.org/downloads/start.html?platform=windows〈=zh_cn&option=php&version=6.5.1
xdebug:2.0.4-5.2.8
Http://www.xdebug.org/files/php_xdebug-2.0.4-5.2.8.dll

[Install Xdebug]

1, the Php_xdebug-2.0.4-5.2.8.dll will be extracted to the PHP installation directory of the Ext folder.
This machine is: D:\Wamp\php\ext
2, modify the php.ini, at the bottom add the following content:
[PHP]
Zend_extension_ts= "D:\Wamp\php\ext\php_xdebug-2.0.2-5.2.5.dll"
Xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
Xdebug.remote_handler=dbgp
[/php]
Note: The value of Zend_extension_ts to your actual installation location, Xdebug will conflict with Zend_optimizer, please comment/delete the Zend_optimizer-related statements in php.ini The value of the xdebug.remote_port is consistent with the contents of the NB Tool-> option-> Debugger port, and the default is 9000;
3, in the Vista environment, the way to load PHP via the Apache module to execute PHP script after loading xdebug will crash, if you want to normal use Xdebug debugging PHP program, you need to change the way PHP is run to CGI, Please add the following in httpd.conf:
[PHP]
#LoadModule Php5_module D:/wamp/php/php5apache2_2.dll
#PHPIniDir "d:/wamp/php/"
scriptalias/php/"d:/wamp/php/"
<directory d:/wamp/php/>
Order Allow,deny
Allow from all
</Directory>

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

Note: The comment drops the configuration statement that loads PHP in a modular way
[/php]

[Start Debugging]

1. New and Open Project
2, open the file you need to debug and set breakpoints.
3, the implementation of the top menu debugging-> Debug "xxx.php", in the pop-up dialog box select "Server-side PHP." Click OK, NB will automatically use your default browser to open the file you want to debug, such as: http://localhost/Comsenz/UCenter_Home/index.php? Xdebug_session_start=netbeans-xdebug。 At this point, you will find that the browser's request has not returned, and NB in the lower right corner of the display "Netbeans-xdebug is running", you can press F7 normal debugging procedures.
If you do not set a breakpoint, the program will automatically suspend execution on the first line of the current file when you perform debugging. If you do not want to automatically suspend execution, uncheck the tool-> option->php-> stop at the first line.
4, form processing debugging can perform debugging-> debugging project, follow up similar, but if you execute to the script that you set breakpoints, NB will automatically interrupt at the breakpoint, waiting for you to debug ha!
5, detailed please refer to NB Official debugging guide http://www.netbeans.org/kb/docs/php/debugging_zh_CN.html

[Reference site]
http://www.netbeans.org/downloads/index.html (NetBeans download)
http://www.xdebug.org/download.php (xdebug download)

Original:Http://www.zvv.cn/blog/show-101-1.html

[ this post was last edited by ZWWS at 2009-3-29 02:55]


1, open the project, set breakpoints. jpg


2, the implementation of debugging. jpg


3, debugging mode. jpg


4, one step debugging. jpg


5, Project debugging (spread). jpg

-->
little Z writing is always so detailed. Top!
PS: The head of the landlord is very ray
1. "Xdebug will conflict with Zend_optimizer, please comment/delete php.ini Optimizer related statements "
    do not know which statements are related to zend_optimizer the landlord can give a detailed
2. Mine is win. Operating system
              php 5.2.9
            & Nbsp; apache 2.11
             & nbsp MYSQL 5.1


I don't know if the way the landlord is configured is the same as
3. I also like the development model of NetBeans, but Xdebug always debugging is not good according to the internet said to do many times
still not     In the early days of the end chose to give up    see the landlord published the specific configuration method is very grateful, but there are above
two questions    I hope to get the fastest and most detailed reply of the landlord    thank you very much
sejie10011 (2009-3-31-11:07:11)
The landlord wrote so detailed. Top!
ZWWS (2009-3-31-12:22:52)
1, oh, the solution to the problem is very important, if you know how the Zend_optimizer is installed, it does not solve the problem?
I found this article in Google with "Zend_optimizer php.ini".
Http://ideacm.com.cn/read.php?12
So you just according to the article in the local php.ini found in the article mentioned in the relevant statement notes are not good, in fact, is "Zend_optimizer." The beginning 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)
The watercress drops.
Niohe (2009-3-31-22:43:54)
Thank LZ 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 this situation.
Http://bbs.phpchina.com/thread-149075-1-1.html
Stepping out after debugging is not available
Zhenjiangdeni (2010-6-23-14:42:03)
Landlord, I have to follow the configuration you said, why, the IDE and the bottom corner is always showing waiting for the connection (Netbeans-xdebug). No way to debug
Luzhou (2010-6-25-19:29:22)
Not bad!
Luzhou (2010-6-25-19:31:05)
Http://zh-cn.netbeans.org/kb/docs/php/debugging.html
Gguoyu (2010-6-25-20:58:24)
Reply 12# Zhenjiangdeni
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.