Using XDebug to trace a PHP web service page

前端 未结 6 1866
我在风中等你
我在风中等你 2020-12-10 07:39

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.

6条回答
  •  死守一世寂寞
    2020-12-10 08:14

    When you are debugging the Ajax request, that one is sent by the browser, in the same navigation context as the other (non-Ajax) requests -- which is why it works fine.


    The request sent by curl is in another, different, context -- and I'm not sure you can hook the debugger into that... But, maybe...

    First of all, here's an information that might prove helpful, quoting the Xdebug's documentation :

    Xdebug contains functionality to keep track of a debug session when started through a browser: cookies. This works like this:

    • When the URL variable XDEBUG_SESSION_START=name is appended to an URL Xdebug emits a cookie with the name "XDEBUG_SESSION" and as value the value of the XDEBUG_SESSION_START URL parameter.
    • When there is a GET (or POST) variable XDEBUG_SESSION_START or the XDEBUG_SESSION cookie is set, Xdebug will try to connect to a debugclient.
    • To stop a debug session (and to destroy the cookie) simply add the URL parameter XDEBUG_SESSION_STOP. Xdebug will then no longer try to make a connection to the debugclient.

    Maybe it might work if you set that cookie "by hand", sending it allong the curl request...

    I suppose you'd first have to get its value, as set by Xdebug at the beginning of the debugging session -- re-using the cookie you have in your browser should be possible, though.

    Note : I've never tried this -- if you try, and it works, could you please confirm it worked ?

提交回复
热议问题