AddThis button
    Add Me    
Syndicate content

Trace PHP code with xdebug

Reserve your domain name now!

/filter/

xdebug

XDebug "logo"I'm very much working on Drupal and once in a while, I just have no clue what the code does... especially when there are callbacks that call callbacks in forever loops.

In those situation, I want to track what's going on. PHP, by default, does not really offer any way of tracking what's happening. Yet, there is a way: xdebug. This is a 3rd party library which you can install with apt-get on Ubuntu and other Debian like systems:

  sudo apt-get install php5-xdebug

Once installed, you may want to change a few things in the .ini file in regard to that new module. I don't think I had to change anything though. I think the defaults are pretty much what you need.

Now, to trace code, you want to use the following two functions:

  xdebug_start_trace($output_filename_with_extension [, $flags]);
  [... php code being traced ...]
  xdebug_stop_trace();

The result of the trace is saved in the specified file: $output_filename_with_extension. As mentioned, the filename must include an extension which is ignored whether or not it is .tx (what xdebug adds). But without an extension, somehow, xdebug ignores the filename and does not trace anything.

Remember that it is likely to generate enormous files. So be careful.

You can find detailed information in the xdebug website.

What about a stack trace?

If what you are looking for is just a stack trace, then you use look into the debug_print_backtrace() function instead. This is part of PHP by default and thus you don't even need to install anything to get to work.

/filter/

test

testx

test

testx

Check this out!

Having problems maintaining your site index?
Each time you read a page you notice that some terms are missing for that page?
Or old terms that do not apply anymore are still being used there?

We have your solution: MO Auto add terms to automatically
add (and remove) terms from your Drupal website pages.

/filter/

Syndicate content

     

Terms of Site Index

Find the page/content you are looking for with our index.

/filter/

Login

/filter/