PHP Netbeans 断点仅针对来自调试会话启动的浏览器的请求命中


PHP Netbeans breakpoints only hit for requests from debug session initiated browser

我正在调试一个PHP代码点火器项目,其中有一个控制器方法来读取php://input并从中获取数据。我在那里放了一个断点,如果我通过浏览器请求该方法(由 netbeans 调试启动),它将成功命中。我有另一个 JAVA 应用程序将数据发送到相同的方法。我需要的是捕捉到这一点。但是 Netbeans 断点不会受到 Java 应用程序发起的请求的命中。无论如何我可以实现这一点吗?提前谢谢。

zend_extension = "C:'xampp'php'ext'php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:'xampp'tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_mode = "req"
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "C:'xampp'tmp"

经过一些研究和调整,我能够配置它。首先,您需要添加

xdebug.remote_autostart = 1
xdebug.idekey = "netbeans-xdebug"

到 php.ini 自动启动调试会话而不XDEBUG_SESSION_START=netbeans-xdebug 默认情况下,Netbeans 只侦听上面的 IDE 键。

然后,您应该在项目属性 ->运行配置 -> 高级中启用不打开 Web 浏览器。我不需要路径映射(我启用了将文件复制到服务器的选项)。现在断点应该命中由任何来源发起的请求(对我来说是Firefox,Chrome和我的Java应用程序)。

参考:

堆栈溢出问题

Xdebug 文档