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_enable_trigger=1
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 https://xdebug.org/docs/all_settings
now use git and clone webgrind into your webroot
git clone https://github.com/jokkedk/webgrind.git
A visit to
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.
webroot/webgrind/config.php
static $storageDir = '/tmp/xdebug';
static $profilerDir = '/tmp/xdebug';