How to use eclipse PDT to debug a PHP program

Source: Internet
Author: User
Tags ini php and php code php debugger window

This article is mainly about how to debug the PHP code with eclipse PDT.
1. Download eclipse, find it from the official web, and verify that the current system has a Java environment, the JDK and the JRE.
2. Install PDT, using the online installation, updated address is already included in the default. It's just a little more cumbersome to update. (If you download the Eclipse version of PDT directly, omit it)
3. Download the debugger, there are two kinds of debugger, one time Xdebug, another time zenddebug, this article uses Xdebug.

The download should be the source code package. Unzip, then CD to directory, then phpize, sometimes there may not be this program, run sudo apt-get install Php5-dev, on it. Then a familiar config program appears./configure a series of black-and-white screen characters, followed by Make,make install. When the latter two commands are executed, sudo permissions may be required because it involves copying the program files to the system directory.


4. Create a Xdebug.ini file in the/etc/php5/apache2/conf.d/, you can use VI or other text programs, add the following configuration items. Configuration content is as follows:

[Xdebug]
zend_extension= "/usr/lib/php5/20090626+lfs/xdebug.so"
Xdebug.remote_handler=dbgp
xdebug.remote_port=9000
Xdebug.auto_trace=on
Xdebug.collect_params=on
Xdebug.collect_return=on
xdebug.max_nestring_level=100
Xdebug.profile_enable=on
Xdebug.remote_enable=on
Xdebug.remote_host=localhost
xdebug.trace_output_dir= "/tmp"
xdebug.profile_output_dir= "/tmp"
Xdebug.idekey=webide
Xdebug.mode=req

The INI file placed in this directory will be automatically loaded by PHP.
At this point, the Xdebug installation configuration is complete.


5. Open Eclipse and select window preference to configure service options first:
Configure debug First, select Debug PHP, and select PHP Debugger as Xdebug. Then configure the server,
Select PHP Servers, then pop-up menu: Then click New, select a name at name, URL configured as the main debug URL.
Then set to default.
Finally configure PHP executables,add a name, path set to/usr/bin/php and then set the INI position in/etc/php5/apache2/php.ini
The SAPI type should be set to CGI, but it seems to be tweaked, and I don't know why.
Finally, the PHP debugger set to become xdebug on it.
6. All ready, create a new PHP project, which can be found in your Apache, and then create a new PHP page, write a piece of code, plus a few breakpoints, and then right-click the PHP page to choose Debug as Phpscript can see the Familiar debugging window, You can see the list of variables, post,get values, and so on.



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.