HomePHP Tracking a Stack of Function Calls with the Xdebug Extension
Tracking a Stack of Function Calls with the Xdebug Extension
If you’re a PHP programmer looking for a comprehensive guide to using the most relevant functions that come with the X-debug extension, then this set of articles might be what you need. Welcome to the last part of a series focusing on debugging in PHP with the Xdebug extension. In seven approachable parts, this series gets you started utilizing this library's numerous features by way of a hands-on approach.
Now that you’ve been introduced to the main subject of this series, it’s time to recapitulate the topics that were treated in the last installment, so you can see more clearly how to link them with the ones that I plan to discuss in this final part.
So, in simple terms, in the aforementioned article I explained how to take advantage of the functionality provided by the “xdebug_time_index()” function to build a couple of timing scripts. I started by using a procedural approach, and then took advantage of the object-oriented paradigm.
In the first case, this function in question was utilized simply for measuring the execution time of a primitive “for” loop, which was very simple to grasp. In the second example, things were more complicated, since it was used as the workhorse of a timer class. Anyway, both examples should be considered only as an introduction to using this handy function in more complex situations.
In addition, the Xdebug extension comes bundled with a few other functions, which, despite their potential functionality, simply can’t be covered completely in a series like this. Despite this inconvenience, in this final part of the series, I’m going to show you how to work with a function of the library called “xdebug_get_function_stack().” This function can be used to keep track of the stack of function calls generated by a PHP script, in this manner completing this starting guide on this helpful extension.
Does this sound good enough for you? Then start reading!