Profiling your PHP apps with webgrind can help you identity what portions of your code are taking up the most execution time, and setting it up with XDebug couldn’t be easier. I am assuming you already have Xdebug installed…

add to your php.ini…

xdebug.profiler_enable = 0 
xdebug.profiler_output_name = cachegrind.out.%t.%p

This sets profiling to be off by defailt, but allow us to activate it by appending ?XDEBUG_PROFILE to the URL. You can read about all the profiling options available on the

now use git and clone webgrind into your webroot

git clone

A visit to /webgrind should confirm that your webgrind installation is working. Since we modified php.ini, restart your web server and test a script by appending the trigger to the URL. Returning to webgrind, you should be able to press the update button and see an analysis of your site.

You can navigate the calls listed by clicking on them, it will take you directly to the code in question for each instance. Note that you would NOT want to have this exposed through any public interfaces!

Webgrind can create call graphs of your profile as well, however please note that you will have to have the graphviz package installed. On OS X you can do this with ease using homebrew (brew install graphviz)

If you have issues with webgrind being able to load your cachegrind files generated by xdebug, check the config.php in the webgrind directory and make sure permissions and paths are suitable for your system on the following variables. For instance, I am using /tmp/xdebug.


static $storageDir = '/tmp/xdebug';
static $profilerDir = '/tmp/xdebug';

Ready to Work Together?

Start A Project