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

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

问题描述

我使用Eclipse和XDebug开发一个依赖于Web服务的PHP应用程序。
我有测试页面消耗我的服务有两种方式:AJAX(使用jQuery)和cURL。



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



但是当我调用服务使用cURL(即从PHP页面内),断点不能运行。即使我打开Break at first line调试器选项,也不能在使用cURL时停止执行。



这是调试器行为吗?我需要给我的cURL电话添加一个听众吗?更改网址?感谢您的时间和精力,
Guy



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



有关如何为我工作的说明:


  1. 使用一个只包含<?php 的简单debug.php文件启动调试会话,它停在第一行,你继续它,它完成执行。

  2. 现在使用cURL(或其他浏览器)请求脚本,将XDEBUG_SESSION_START = ECLIPSE_DBGP添加到其路径中(我甚至认为此添加是可选的)


希望有帮助。


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.

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.

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.

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.

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. 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

Hope ths helps.

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

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