This article is mainly about how to debug PHP code with eclipse PDT.
1. Download eclipse, find it on the official website, and verify that the current system has a Java environment, the JDK and the JRE.
2. Installed PDT, the use of an online installation, the update address is already included in the default. It's just more trouble to update. (Omit if you download the Eclipse version that carries PDT directly)
3. Download the debugger, the debugger has two kinds, one time xdebug, another time zenddebug, this article uses xdebug.
The download should be the source code package. Unzip, then CD to the directory, then phpize, sometimes there may not be this program, run sudo apt-get install Php5-dev, on it. Then the familiar config program appears./configure a string 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/etc/php5/apache2/conf.d/, you can use VI or other text programs to add the following configuration items. The 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 loaded automatically by PHP.
At this point, the installation configuration for Xdebug has been completed.
first configure debug, choose PHP Select Debug, PHP debugger selected as Xdebug. Then configure server,
select PHP Servers, and then pop-up the menu: then click New, choose a name at name, and the URL is configured as the main URL for debugging.
and then set to default.
last configuration php executables,add a random name, path set to/usr/bin/php and set INI location in/etc/php5/ Apache2/php.ini
SAPI type should be set to CGI, but it seems to be adjusted but I don't know why.
finally set the PHP debugger to Xdebug.
6. Everything is ready, create a new PHP project that can be found in your Apache, create a new PHP page, write a piece of code, add a few breakpoints, then right-click on the PHP page and select Debug as Phpscript can see the Familiar debugging window, you can see the variable list, Post,get value and so on.