Installing XDebug and KCacheGrind is normally a straightforward task. However, I found it particularly fiddly to get working on a Mac (running Mountain Lion) with Vagrant.
A few VMs later, I figured out the quickest way to achieve this setup:
SSH onto Vagrant VM and install XDebug
sudo apt-get install php5-xdebug
Create a writable directory for cachegrind files
chmod 777 /vagrant/cachegrind
Add the following to php.ini to enable XDebug profiler
sudo vim /etc/php5/apache2/php.ini
xdebug.profiler_enable = 1
xdebug.profiler_append = 1
xdebug.profiler_output_dir = "/vagrant/cachegrind"
xdebug.profiler_output_name = "cachegrind.out.%t.%p"
sudo service apache2 restart
Install QCacheGrind on Mac
brew install qcachegrind
Install Graphviz (req. to produce graphs)
brew install graphviz
By default, Graphviz installs the dot binary to /usr/local/bin/dot, which QCachGrind can’t find. To get the graphs working, you need to add the following symlink:
sudo ln -s /usr/local/bin/dot /usr/bin/dot
Refresh website, fire up QCacheGrind.app, open cachegrind file and you’re good to go: