可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
My development web server is currently a XAMPP 1.7.3 on my localhost (Win XP).
I just set up my Eclipse 3.6 PDT with XDebug. It works fine, if I debug a file as a "PHP script", but when it comes to debugging it as a "PHP web page", XDebug ignores the breakpoints completely.
Only a manually inserted xdebug_break() inside the code stops the debugger. This isn't very useful, if you want to use conditions with Eclipse's breakpoints.
Here my config:
php.ini:
zend_extension = "C:\xampp\php\ext\php_xdebug.dll" xdebug.remote_autostart=1 xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=localhost xdebug.remote_port=9000 xdebug.remote_idekey="ECLIPSE_DBGP"
phpinfo()
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies with Xdebug v2.0.6-dev, Copyright (c) 2002-2009, by Derick Rethans
...
xdebug xdebug support enabled Version 2.0.6-dev Supported protocols Revision DBGp - Common DeBuGger Protocol $Revision: 1.125.2.7 $ GDB - GNU Debugger protocol $Revision: 1.87.2.1 $ PHP3 - PHP 3 Debugger protocol $Revision: 1.22 $ Directive Local Value Master Value xdebug.auto_trace Off Off xdebug.collect_includes On On xdebug.collect_params 0 0 xdebug.collect_return Off Off xdebug.collect_vars Off Off xdebug.default_enable On On xdebug.dump.COOKIE no value no value xdebug.dump.ENV no value no value xdebug.dump.FILES no value no value xdebug.dump.GET no value no value xdebug.dump.POST no value no value xdebug.dump.REQUEST no value no value xdebug.dump.SERVER no value no value xdebug.dump.SESSION no value no value xdebug.dump_globals On On xdebug.dump_once On On xdebug.dump_undefined Off Off xdebug.extended_info On On xdebug.idekey no value no value xdebug.max_nesting_level 100 100 xdebug.profiler_aggregate Off Off xdebug.profiler_append Off Off xdebug.profiler_enable Off Off xdebug.profiler_enable_trigger Off Off xdebug.profiler_output_dir C:\xampp\tmp C:\xampp\tmp xdebug.profiler_output_name xdebug_profile.%p xdebug_profile.%p xdebug.remote_autostart On On xdebug.remote_enable On On xdebug.remote_handler dbgp dbgp xdebug.remote_host localhost localhost xdebug.remote_log no value no value xdebug.remote_mode req req xdebug.remote_port 9000 9000 xdebug.show_exception_trace Off Off xdebug.show_local_vars Off Off xdebug.show_mem_delta Off Off xdebug.trace_format 0 0 xdebug.trace_options 0 0 xdebug.trace_output_dir C:\xampp\tmp C:\xampp\tmp xdebug.trace_output_name trace.%c trace.%c xdebug.var_display_max_children 128 128 xdebug.var_display_max_data 512 512 xdebug.var_display_max_depth 3 3
Does anyone know what I'm doing wrong?
Thanks in advance!
回答1:
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.
回答2:
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)
!!!!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
Window>Preferences>PHP>Servers
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
回答3:
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).