Installing XHGui

There’s a new version of XHGui (well, a few months old) and it’s fabulous! It’s got a few new dependencies though so I thought I’d write down how I set up my version, in case it’s helpful to anyone else (and so I feel like a pro next time I have to do this!). If you’re not familiar with XHGui it’s a fabulously easy and friendly way to profile your application; to understand which method calls in a page take the time and how many times they are made, so you can improve the performance of your application. All these instructions are for my 32-bit Ubuntu 12.10 system, hopefully they will work for you or you’ll be able to adapt them as appropriate.


XHGui needs version numbers or fluffy animal names, because this is a really major release and quite different to what went before in both technology and in looks. In particular, it now uses MongoDB. If you’re not familiar with MongoDB, it’s a super-friendly NoSQL database that makes a really handy backend for this kind of unstructured data – because every run of every page will look different. Therefore you will need:

  • MongoDB itself
  • The pecl extension for mongo
  • The xhprof pecl extension (read on if you’re using PHP 5.4, there’s a gotcha)

To get MongoDB, go to and find the instructions for your system. I use their apt repositories since they update quicker than Ubuntu’s (for obvious reasons) and Mongo is a pretty young product so it updates a lot.

The pecl extension for Mongo should be easy enough:

pecl install mongo

The XHProf extension should be that easy, but isn’t. There’s an xhprof-beta package available, but I found that this did not work when installed on my system. This turns out to be because it’s not ready for PHP 5.4, so follow the instructions at for now. The change is in the github project, so I assume facebook will roll a new release of xhprof at some point. This was the most difficult bit of setup for me so if you get this far, you’re almost there!

Many thanks to the facebook engineers for rolling a pecl release that will work with 5.4+ as well as the earlier versions. You simply need to do:

pecl install xhprof-beta

And you’re good to go.

Installing XHGui

You’ll find the main project here: and I forked the repo onto my github account and cloned that, you could download the code direct from their repo, it doesn’t matter. The project README is great and will show you how to set up, making the cache directory writeable and adding a line to enable profiling to your virtual host configuration (don’t forget to restart Apache).

At this point, you’re logging data when you make requests to whichever virtual host you added XHGui to, but how do you see the results? Set up another virtualhost (or if you’re lazy like me, start the PHP 5.4 webserver instead) for the directory /web/webroot and then request it. You will see a list of all the requests you have made, with the option to filter these in various ways. You can also drill into the detail for an individual request:


From this point you can start to drill in and look at all the various statistics collected by XHGui, identify pain points in your application, and compare two runs to measure how much you have improved things when you optimise.

7 thoughts on “Installing XHGui

  1. I have only recently looked at the two XHGui based projects I’ve worked on and asked “Oh Gosh, what have I doneā€½. I’m open to suggestions on how to resolve this naming conundrum.

  2. Hi Lorna,

    I’m very glad my post on compiling xhprof helped!

    As a side-note, the last pecl-packaged release of xhprof (0.9.2) was bundled mid-2009; I doubt they’ll *ever* release an updated one.

  3. Lorna, since you asked so nicely ;-)
    I’ve rolled an updated pecl package from the current tip of our github repo and pushed it to the pecl site.
    I very briefly tested the package before inflicting it on the world; it seemed to work for me, but YMMV!
    Double checked that `sudo pecl install xhprof-beta` does something reasonable. Enjoy!

  4. The new callgraph is not very useful, unless you miss lava lamps. Filtering by domain is absent, as is access control. Gotta go back to the older ver. It was fun to play with, though! :)

  5. Pingback: Saving cycles… O’rly? (Stupid Series) | CrazyCodr's blog

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.