如何为 JetBrains PhpStorm 2020.1 配置 Xdebug?

How to configure Xdebug for JetBrains PhpStorm 2020.1?

所以,我非常高兴地使用 PhpStorm 调试我的 PHP 代码 - 直到 Windows 变得严重损坏......我的备份机制并没有我想象的那么好(让这成为我们许多人的一个教训:-( )

这是我 php.ini 的相关部分:

[PHP]

[Xdebug]

; ---- trying to follow PHP storm's advice

zend_extension = "e:\coding\Web_development\php\php\ext\php_xdebug-3.0.1-7.3-vc15-x86_64.dll"

xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
;xdebug.remote_port = 9000
;xdebug.remote_mode = req
xdebug.idekey="xdebug"

; ----------   previously worked 
;xdebug.remote_enable=1
;xdebug.remote_host=127.0.0.1
;xdebug.remote_port=9000
;xdebug.remote_autostart=1
;xdebug.remote_handler=dbgp
;xdebug.idekey="xdebug"
;xdebug.remote_log=m:\xdebug.log
;xdebug.profiler_enable=0
;xdebug.profiler_enable_trigger=0
;;xdebug.profiler_output_dir="F:\DropBox\programs\xampp\htdocs\_PHP_profile"
;xdebug.profiler_output_name=cachegrind.out.%s.%t

而且,这是 PhpStorm 所说的:

BUT https://xdebug.org/docs/all_settings 中的大部分实际上并不存在 - 好像其中一些设置不再 relevant/supported.

那么,任何人都可以 post php.ini 的相关 [Xdebug] 部分用于 PHP 风暴 2020.1 吗?

吸引您的不是 PhpStorm,而是 XDebug:XDebug 3.0 came out a couple of weeks ago, and has completely overhauled the settings. As mentioned in one of the messages in your screenshot there is an upgrade guide on the XDebug site

PhpStorm 的检查脚本似乎尚未完全更新,因此它建议混合使用新旧设置。

最重要的变化是:

  • 新的 xdebug.mode 设置可以一次切换一大堆设置,而不必记住正确的组合。因此,一些设置根本不再需要。
  • 默认端口现在是 9003 而不是 9000,因为一些其他流行的软件使用相同的端口。
  • 许多剩余的设置已重命名,以便更清晰。

查看您的旧配置:

zend_extension = "e:\coding\Web_development\php\php\ext\php_xdebug-3.0.1-7.3-vc15-x86_64.dll"
   ; this tells PHP to load the XDebug extension
   ; note that the file name includes the version number, confirming that you're using v3
xdebug.remote_enable=1 
   ; now implied by xdebug.mode=debug
xdebug.remote_host=127.0.0.1 
   ; renamed xdebug.client_host
xdebug.remote_port=9000 
   ; renamed xdebug.client_port
   ; also, the default is now 9003 not 9000
   ; so either set to 9000 here, or tell PhpStorm to use port 9003
xdebug.remote_autostart=1 
   ; replaced with xdebug.start_with_request=yes
xdebug.remote_handler=dbgp 
   ; no longer needed, as there was only one valid value
xdebug.idekey="xdebug" 
   ; still supported, but not usually needed
xdebug.remote_log=m:\xdebug.log 
   ; replaced by xdebug.log
xdebug.profiler_enable=0 
   ; now implied by xdebug.mode=debug
xdebug.profiler_enable_trigger=0 
   ; now implied by xdebug.mode=debug
xdebug.profiler_output_dir="F:\DropBox\programs\xampp\htdocs\_PHP_profile" 
   ; not needed for debugging
xdebug.profiler_output_name=cachegrind.out.%s.%t 
   ; not needed for debugging

所以我相信你的新配置应该是这样的:

zend_extension = "e:\coding\Web_development\php\php\ext\php_xdebug-3.0.1-7.3-vc15-x86_64.dll"
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9000 ; or 9003, but should match the setting in PhpStorm
xdebug.start_with_request=yes
xdebug.idekey="xdebug"
xdebug.log=m:\xdebug.log