Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to do a "forward trace" in PHP?

I'm familiar with the debug_backtrace function in PHP, and really find it useful. However, I have a specific, very messy case where I need to be able to do the reverse - stick a function call in somewhere and have it give me a list of every function that's called after that point until the page is completely loaded.

We do have XDebug installed, and for most projects I use it. This is a really messy codebase, though, with a lot of ajax and php code that's actually created as strings and rendered (I did NOT write this code!) and none of us have ever been successful in getting a debugger to work.

like image 967
EmmyS Avatar asked Nov 11 '22 12:11

EmmyS


1 Answers

PHP has a ticks feature, which can get called at the execution of each statement.

Using the ticks feature, my answer describes a class CStatemenTracer, which write a call trace alongside the execution of your application.

Might be a starting point.

like image 86
SteAp Avatar answered Nov 15 '22 05:11

SteAp