使用 XDebug 跟踪 PHP Web 服务页面 [英] Using XDebug to trace a PHP web service page

查看:28
本文介绍了使用 XDebug 跟踪 PHP Web 服务页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Eclipse 和 XDebug 来开发一个依赖于 Web 服务的 PHP 应用程序.我的测试页面以两种方式使用我的服务:AJAX(使用 jQuery)和 cURL.

I'm using Eclipse and XDebug to develop a PHP application that relies on web services. I have test pages that consume my services in 2 ways: AJAX (using jQuery) and cURL.

我将断点添加到我的服务页面并启动调试器.当我从 AJAX 调用服务时,执行在断点处很好地停止,并且我得到了我的变量、逐步控制等.

I add breakpoints to my service page and launch the debugger. When I call the the service from AJAX, execution stops nicely at the breakpoint, and I get my variables, step-by-step control etc.

但是当我使用 cURL(即从 PHP 页面中)调用该服务时,断点无法运行.即使我打开在第一行中断"调试器选项,在使用 cURL 时也无法停止执行.

But when I call the service using cURL (i.e. from within a PHP page), the breakpoints fail to function. Even if I turn on the "Break at first line" debugger option, I cannot get the execution to stop when using cURL.

这是调试器行为吗?我需要在 cURL 调用中添加一个听者吗?修改网址?还是 XDebug 的限制?

Is it a debugger behavior? Do I need to add a hearder to my cURL calls? Alter the URL? Or is it an XDebug limitation?

感谢您的时间和努力,家伙

Thanks for your time and effort, Guy

推荐答案

我还不能发表评论,所以我把这个作为答案发布.

I can't comment yet, so I post this as an answer.

你能在一个会话中调试多个 AJAX 请求吗?当您尝试使用 cURL 进行调试时,您的调试会话是否仍在 Eclipse 中运行?

Can you debug more than one AJAX request in one session? Was your debug session still running in Eclipse when you tried to debug using cURL?

关于它如何为我工作的描述:

Description on how it works for me:

  1. 使用一个简单的 debug.php 文件启动调试会话,该文件只包含一个 <?php 而没有其他内容.它停在第一行,您继续"它并完成执行.
  2. 现在使用 cURL(或其他浏览器)请求脚本,将 ?XDEBUG_SESSION_START=ECLIPSE_DBGP 添加到其路径(我什至认为这个添加是可选的)
  3. 您的脚本应显示在停止在第一行的调试视图中
  1. Start debug session with a simple debug.php file that contains only a <?php and nothing else. It stops on the first line, you "continue" it and it finishes execution.
  2. Now request the script using cURL (or another browser) adding ?XDEBUG_SESSION_START=ECLIPSE_DBGP to its path (I even think this addition is optional)
  3. Your script should show up in the debug view stopped at the first line

希望对您有所帮助.

这篇关于使用 XDebug 跟踪 PHP Web 服务页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆