XAMPP 1.7.3, Eclipse PDT & XDebug - Debugging a PHP web page in Eclipse never stops at breakpoints

Deadly 提交于 2019-12-07 17:58:39

Wrong set path mappings in Eclipse were the problem.

Additional info: Always use the latest version of XDebug from www.xdebug.org, the version in XAMPP (2.0.6) has some bugs where variables were <Uninitialized>. This got resolved in the current 2.1.0 release.

This "could" be of help for some people who are struggling with debugging in php under eclipse

Config: - Win7 pro on virtual box - Eclipse Luna luna service release 2 (4.4.2) with PDT plugin installed on c: - wamp 2.5 (php 5.5.12, apache 2.4.9)

On the desktop:

Click on windows status bar wamp icon (outside of eclipse, down on the right of your desktop)

  • click PHP> PHP Settings

    Tick Xdebug remote debug / profiler / profiler enable trigger until it appears ticked (need to try few times before it works and errors can appear but ignore them)

  • click PHP> PHP.ini

    • Add at the end xdebug.remote_port=9001
    • Save and restart all wamp services

!!!!WARNING!!!! This last step is changing in fact the c:/wamp/www/bin/apache/apache2.4.9/bin/php.ini NOT the one c:/wamp/www/bin/php/php5.5.12/php.ini but it still works as described previously

In eclipse:

Window>Preferences>PHP>PHP Executable

  • Executable path c:/wamp/bin/php/php5.5.5.12/php.exe (browsed)
  • SAPI: CLI

Window>Preferences>PHP>Debug

  • Check/set server settings Zend debugger
  • Check/set CLI settings Xdebug

Window>Preferences>PHP>Debug>Installed Debugger

  • Xdebug Port 9001

Window>Preferences>PHP>Servers

  • Debugger: Zend Debugger

Select php file to debug and then Run>Debug>Debug Configurations

  • give a name ex mydebugconfig
  • click (blank page icon) Add Web Application
  • select path to the file to debug
  • select thumbnail Server and select Default PHP Web server
  • click Configure and check if Zend Debugger is choosen
  • select thumbnail Debugger and check Server Debugger Xdebug
  • click Configure and check/set port to 9001 and finally Debug button in the same window and it should work (at least on on my machine what is not too bad after a day of looking around)

NB: It's also possible to select file on the left eclipse explorer frame > Run > Debug > Debug Configurations and the previous mydebugconfig created)

For your information end of file c:/wamp/www/bin/apache/apache2.4.9/bin/php.ini

; XDEBUG Extension

zend_extension = "c:/wamp/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11.dll"
;
[xdebug]
xdebug.remote_enable = off
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.show_local_vars=0

and end of file c:/wamp/www/bin/apache/apache2.4.9/bin/php.ini

; XDEBUG Extension

zend_extension = "c:/wamp/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11.dll"
;
[xdebug]
xdebug.remote_enable = On
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.show_local_vars=0
xdebug.remote_port=9001
trejder

For all those, that are still fighting with this problem, some handy tips.

Check which version (package) of Eclipse you have? It turns out, that Helios package has some bugs and doesn't stops on breakpoints, when you debug your application as Web Application. Debugging works only, if you run it as PHP Script. Which makes it pretty useless for debugging process.

You should consider either reverting to older Galileo Package Eclipse for PHP Developers or installing newest Eclipse Juno (or even newest developer version of Eclipse Kepler), which doesn't have PDT support build in, but you can easily add it to then, using Help > Install New Software.. (point it to http://download.eclipse.org/tools/pdt/updates/release).

These versions are reported to be able to debug as Web Application, respecting breakpoints.

Also, remember, that Xdebug must be run as Zend Extension in order to support breakpoints! In other words remove extension=xdebug.so (on Linux or xdebug.dll on Windows) line from your php.ini and replace it with zend_extension=/full/path/to/xdebug.so (on Linux or zend_extension=X:\full\path\to\xdebug.dll on Windows). Zend extensions requires full path, even if they're put into /php/ext folder, as regular PHP extensions. You'll find more info on this in Xdebug FAQ (look for an answer to "Xdebug is only loaded as PHP extension and not as a Zend Extension" question).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!