Debug PHP Application with XDebug & KCacheGrind on Ubuntu 12.04

Install Xdebug, KCacheGrind on Ubuntu 12.04

Install PHP-Xdebug

sudo apt-get install php5-xdebug


Open php.ini, configure some line:
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = /tmp
xdebug.profiler_enable_trigger=On

 

Restart your apache

Check your phpinfo, and should contain xdebug information.

 

Install KCacheGrind

sudo apt-get install kcachegrind

 

Append XDEBUG_PROFILE=1  ( in the GET/POST request to your script )
Example, run your app at browser:

http://localhost/myapp/index.php?r=my/dashboard&XDEBUG_PROFILE=1

 

Then open KCacheGrind, and open your file in /tmp folder:
Example: cachegrind.out.11445

Resources:
http://www.xdebug.org/
https://kcachegrind.github.io/html/Download.html

Advertisements