Bruiser
Bruiser

Reputation: 11887

How to get a stack-trace via api-call in xdebug?

We are using xdebug and the tracing works as advertised during code execution via..

 function someGetUsersHelper() {
     xdebug_start_trace();
     [SOME CODE HERE]
     xdebug_stop_trace();
}

It however only traces the wrapped part of the code if the page/script is executed via loading the full page in the browser via requesting

index.php

But tracing does not work, when we call the function as an api call via

index.php?api=getUsers

Even though the very same function is executed successfully it does not trace.

As an additional note: Tracing also works if the function is called from phpunit testcases or if we set xdebug.auto_trace = 1 in the php.ini, but that leaves us with a very long, messed up trace file.

So the question is this:

Thanks a lot!!

Upvotes: 2

Views: 1479

Answers (1)

Thomas Berger
Thomas Berger

Reputation: 1870

I could not say why the trace is not working. But you could try this:

  1. Add the option xdebug.trace_enable_trigger=1 in your php configuration
  2. Now you could start a xdebug by adding XDEBUG_TRACE as POST/GET Parameter or as a cookie

There is also a Firefox Plugin called Easy XDebug to set the flags

Upvotes: 3

Related Questions