Installing XHProf on a Mac with Homebrew

Update 12/3/2013: the absolute easiest way is simply https://github.com/cam8001/php-xhprof-mamp

There are several ways to install XHProf on your mac in a MAMP environment. After a lot fails, the easiest way in my opinion is using Homebrew. The rest of the article assumes you already have this installed, so let's get to the XHProf install.

  1. Download the XHProf Homebrew Formula from https://github.com/msonnabaum/homebrew/blob/92f3795d2dcd5e74fb6f47a30b4f... and copy this file to /usr/local/Library/Formula/
  2. Fire 'brew install autoconf' to make sure autoconf is installed.
  3. Fire 'brew install xhprof' on the command line. You might get an error downloading the pcre package (depending on your homebrew version):
    Error: Failure while executing: /usr/bin/curl -f#LA Homebrew\ 0.8\ (Ruby\ 1.8.7-249;\ Mac\ OS\ X\ 10.7.3) ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.bz2 -o /Users/swentel/Library/Caches/Homebrew/pcre-8.12.tar.bz2
    In that case, go to https://github.com/mxcl/homebrew/blob/master/Library/Formula/pcre.rb and download that file into /usr/local/Library/Formula/ and run the command again from shell.
  4. The extension is now built and can be copied to your MAMP installation:
    cp /usr/local/Cellar/xhprof/0.9.2/xhprof.so /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/ 
  5. Go to your php.ini file in your MAMP installation and paste following code and restart MAMP.
    ;This is the directory that XHProf stores it's profile runs in.
That's it. Should take you about 5 minutes. Took me a couple of wasted hours, but it's worth doing. And now you can finally toggle the XHProf option on the devel settings page in case you're working with Drupal.

Other resources about installing XHprof:


php, mamp, xhprof, planet
Subscribe to RSS - xhprof

You are here