Brief Discussion on Eclipse PDT Debugging PHP Program

  • 2021-06-28 11:58:41
  • OfStack

1. Download eclipse, find it on the official website, and confirm that there are java environments in the current system, namely jdk and jre.

2. pdt is installed online and the update address is already included by default.It's just a hassle to update. (If you download the Eclipse version with PDT directly, you can omit it)

3. Download the debugger, there are two kinds of debuggers, one is xdebug, the other is zenddebug, this paper uses xdebug.

The source code package should be downloaded.Unzip, then cd to the directory, then phpize, sometimes you may not have this program, run sudo apt-get install php5-dev, you can.Then you will see the familiar config program. /configure with a series of black and white screen characters, followed by make, make install.When the last two commands execute, sudo permissions may be required because it involves copying program files to a system directory.

4. Create an xdebug.ini file in/etc/php5/apache2/conf.d/which can be used with vi or other text programs to add the following configuration items.The configuration 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

ini files placed in this directory are automatically loaded by php.

At this point, the xdebug installation configuration has been completed.

5. Open eclipse and select window preference to configure the service options:

Configure debug first, select php to select debug, and select debugger for php to xDebug.Next, configure Server,
Select PHP Servers, then pop up the menu: then click new, choose a name at Name, url is configured as the primary url for debugging.
Then set to default.
Finally, configure PHP Executables, add give it any name, path set to/usr/bin/php and then set the location of ini at/etc/php5/apache2/php.ini
SAPI Type should be set to CGI, but it does not seem to be adjustable and I don't know why.
Finally, set PHP debugger to XDebug.

6.1 Ready, create a new php project, which you can find in your apache, then create a new php page, write a code, add a few breakpoints, then right-click the php page and select debug as phpscript to see the familiar debugging window, you can see the list of variables, the values of post, get, and so on.


Related articles: