Xdebug + Eclipse Single Step tracing debug PHP code ____php

Source: Internet
Author: User
Tags php and php debug php debugger php script phpinfo
Tools Introduction: 1. Xdebug

Xdebug is an open source PHP debugger (a debug tool) that is powerful enough to track, debug, and analyze the PHP program's health. Xdebug now the latest version is xdebug 2.1.0, download page is http://xdebug.org/download.php, note that the download link in the page has multiple (the following figure), according to their own number of computers and PHP version to choose, Figuring out the version of your PHP and whether it's thread-safe (viewed through the Phpinfo function), the PHP5.3 version of the user also needs to know which compiler compiled the PHP to decide to download the VC6 or VC9 version. For example, my PHP version is 5.2.x and thread safe, so choose 5.2 VC6 (bit) download, the filename is php_xdebug-2.1.0-5.2-vc6.dll:

2. Eclipse

Eclipse is an open source, java-based, extensible development platform. For its part, it is just a framework and a set of services for building the development environment through plug-in components. Use it, you can bring a lot of convenience for our PHP development, software can be downloaded on its website.

installation and configuration: 1. Install Xdebug

The installation of Eclipse will not be said. Xdebug installation method is not difficult, first of all downloaded to the file renamed Php_xdebug.dll placed in the ext/directory of PHP, and then modify the php.ini file, add the following lines at the end of the file:

[Xdebug]
; Specify the location of the xdebug extension file (path Please adjust according to your situation)
Zend_extension_ts = "F:/library/php_xdebug-2.1.0-5.2-vc6.dll"
; Enable Xdebug remote Debugging
xdebug.remote_enable = 1
; The following Xdebug debugging options are actually default values
Xdebug.remote_host = localhost
Xdebug.remote_port = 9000
Xdebug.remote_mode = req
Xdebug.remote_handler = DBGP

The TS in Zend_zend_extension_ts are thread safe, and if your PHP is not thread safe, write Zend_extension. See http://xdebug.org/docs/all_settings for complete configuration items and instructions.

After saving php.ini reboot the server, view the output of phpinfo (), if you can see the following screen on the page installed successfully:

2. Configure the debug option in Eclipse

I'm using eclipse for PHP developers Helios, and the other versions are similar. First select PHP-> Debug (below) on the left side of the window-> Preferences window, and select Xdebug in the PHP debugger to the right of the windows, which has a configure link to the right of this option. Click here to set the Xdebug, make sure that the port number that Xdebug uses is the same as specified in php.ini file (typically 9000), the following two items are set up Web server and PHP interpreter, and then the following break at Line indicates that the start of debugging is disconnected at row 1th:

Program Debugging:

Set up after the program can be debugged, click on the tool bug-> Debug AS, here you can choose to Web page form or PHP script in the form of debugging (as shown below):

If it goes well, the current workspace view will switch to PHP debug, and then the program will be disconnected on line 1th, and then you can do a single step (the following figure), debugging methods do not say more, their own groping, in short, is very convenient:

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.