Dessert #12 - Debugging requestAction
Posted on 19/9/06 by Felix Geisendörfer
You can regard this as a general php debugging tip, but I found it pretty useful when either working with Object::requestAction() (you probably mostly use it from within the controller which extends object), or when having problems to understand a function call sequence in general.
The basic problem is that sometimes you want to find out which function called the function you are in right now, or even see the entire sequence of function calls that led to your current function being executed. In that case php's debug_backtrace() comes really handy. However the array it returns is a little too long and complex for what you usally need. In my case that is a list of Class::function()'s that were called. So what I did was to write a little snippet that I can insert by using a shortcut of my IDE. The code itself looks like this:
foreach ($backtrace as $trace)
{
debug(@$trace['class'].'::'.@$trace['function'].'()');
}
Usally when I paste it, it's 1 line long, but I split it up so you can read it a little better on here. For those of you who use some advanced debugging extensions or additional classes, of course, this will seem like a joke, but I believe in light weight debugging, because as soon as you need huge debugging frameworks you are in huge trouble ; ). So feel free to post your approaches to debugging function sequences, but keep in mind that this is only ment to be a quick & dirty snippet I trigger by pressing a hotkey, but which has served me well so far ; ).
--Felix Geisendörfer aka the_undefined
You can skip to the end and add a comment.
This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.