Install XDebug and WebGrind on CentOS for debugging and profiling

webgrindXdebug is a PHP extension created by Derick Rethans, one of the PHP core developers. Webgrind is an Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick’n’dirty optimizations it does the job. This article will show how to install XDebug and WebGrind into your development environment for development work.

  1. Install XDebug

  2. Add XDebug to PHP

  3. Restart apache.

  4. To test it, create a testxdebug.php file with the following content


    , and run php -e testxdebug.php
  5. Install WebGrind

  6. Done, run webgrind from your browser to check debugging/profiling information
  7. We can also install KCacheGrind to view debug information on Linux desktop.

Some Notes

  • By default, XDebug does not enable profiling, we must enable it explicitly as in the above configuration
  • If just running XDebug for some specific URL/file, we can use configuration

     on .ini file, and then we can enable profiling with GET/POST parameter XDEBUG_PROFILE, e.g. http://localhost/samplepage.php?XDEBUG_PROFILE:
  • If we need to display graph with WebGrind, we must have graphviz installed:

    , and then, change the configuration file

Leave a Reply