Tech Blog :: osx


Jan 14 '12 3:55pm

How to install xhprof on OSX (Snow Leopard or Lion) and XAMPP

Note: The same instructions apply to XDebug and possibly every other PECL module in this environment.

XHProf is a very neat PHP profiler. Documentation and general installation instructions are not hard to come by, but none of the examples I found had the right steps for my particular setup, Mac OSX Lion with XAMPP running php 5.3. (Should apply also to OSX Snow Leopard.) So this post fills in that hole; for everything else regarding xhprof look elsewhere.

The problem is the "architecture" that xhprof compiles to; OSX and xhprof are 64-bit but XAMPP is apparently 32-bit. (If you're using MAMP instead of XAMPP, you'll have a similar problem; here is a solution for that.)

After trying multiple variations, the solution that worked was adapted from this memcached-on-xampp post):

  1. Download the latest copy of xhprof
  2. sudo phpize (not sure if this is actually necessary. You may run into problems here; find the solution to that elsewhere.)
  3. If you've been trying other methods that failed, clean up the old junk: sudo make clean
  4. The most important part:
    sudo MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config-5.3.1
  5. sudo make
  6. sudo make install
  7. Add to your php.ini:
    xhprof
    extension = xhprof.so
    xhprof.output_dir = "/Applications/XAMPP/xhprof-logs"

Then run php -i | grep xhprof and if it worked, it should tell you which version you're running. If it fails, it will say, xhprof.so: mach-o, but wrong architecture in Unknown on line 0.

Good luck!

Update: It's worth mentioning, you'll probably also need to install Graphviz so xhprof can find the dot utility to generate graphics.

Aug 4 '11 2:58pm
Tags

Upgrading to OSX Lion: Some Gotchas

I upgraded my MacBookpro to OSX Lion today. It's $30 in the App Store (or copy the DMG from someone who paid and it's free). ArsTechnica has an extremely comprehensive review of Lion if you want the full details. Here are a few minor hiccups I ran into:

• Custom symlinks in /usr/bin were removed. So far I've noticed the symlink for Git missing (/usr/bin/git -> /usr/local/git/bin/git), I put it back. (There's also a StackExchange thread about this.)

• The AFP protocol on my ReadyNAS - which I was using, among other things, for Time Machine backups - is not compatible with Lion. Fortunately the Netgear folks are quick and have a new beta release with the new protocol; I installed that it seems to be working fine.

• I turned off the new mobile-inspired "natural" scrolling. It doesn't feel natural to me, and I don't want to get disoriented every time I use someone else's computer.

• The new (also mobile-inspired) bouncy scrolling is slightly annoying too, but I can't figure out how to disable that.

• The OS seems to handle memory much better. I'm running all the usual apps, but it's turning a lot more of the "active" RAM (yellow in Activity Monitor) into "free" (green) RAM. I'm not sure what the overall performance impact is yet, but it's nice to see the OS [apparently] cleaning up dead memory better than before.

• Some of the startup items in my user account were removed, I put them back.

Otherwise it's been pretty smooth. I like the new Spaces+Exposé hybrid called Mission Control. One of the main reasons I upgraded so quickly was the new full-disk encryption built in, which I'll set up as soon as I can reboot.