Installing Intl on PHP and MAMP

Compiling the Intl extension for PHP under MAMP is actually quite simple. I explain how and include a few solutions to “gotcha” problems along the way.

If needed, download the relevant ICU package, and extract it. Ensure your MAMP PHP binary is in your $PATH environment string. Snippet from StackOverflow:

Opening a Terminal to the extracted directory, I then compiled the code:

As I did not have autoconf, I installed it using Brew. Alternatively, you can compile it from source if you do not have Brew.

The next few steps are where I had some problems. I was getting strange errors:

fatal error: 'php.h' file not found
and
"ERROR: `phpize' failed"

Digging around, it turns out there’s a bit of a strange bug here. It can be quite simply solved by downloading/updating XCode from the App Store and symlinking the XCode SDK headers to the MAMP directory:

After this, simply install Intl using PECL:

If you’ve downloaded and installed XCode just now, you may get the error:

This is simply a MacOSX/XCode licensing issue. You can solve it by launching XCode or just typing:

to trigger the licence terms and agreements prompts. Afterwards, run the pecl install command again to install the extension.

Once that’s done, add the extension to your PHP config. In MAMP, this can be found under File > Edit Template > PHP > PHP 5.6.10. Add extension=intl.so to the list of loaded extensions.

MAMP should be restarted for this to take effect.

If you have any comments/questions, please leave them below!

Enabling memcache under MAMP

I know the tech is a bit old, but sometimes you need to make do with the tools you’ve been given. Here’s how I enabled memcache under MAMP.

First, grab the precompiled binary file (memcache.so) from here. There were no problems using this on Snow Leopard (for me, at least).

Second, copy the file to your MAMP extensions directory. You should be able to find it here: /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-[date].

Next, you’ll need to enable the extension in MAMP. Switch it off, then open up php5.ini by going to File > Edit Template > PHP5 php.ini

Find the extensions section (about line 540 or so) and add this line to the list of extensions:

Once that’s done, save php.ini and reboot MAMP. You should be able to see an entry for memcache when opening your phpinfo page.

Reclaiming your favicons when using MAMP

I use MAMP Pro to manage my local virtual hosts. It’s about a hundred times more convenient than Apple’s “native” Apache/PHP install (unfortunately a sad truth).

One annoying facet, though, is that MAMP will force its favicon when you’re using a MAMP-managed virtual host. Here’s how to get rid of this “feature” and reclaim your presumably awesome favicon.

First, make sure MAMP is not running Apache. Then, go to File > Edit Template > Apache httpd.conf

Once you’ve got the configuration file open, look for the line (roughly 625 for me):

Alias /favicon.ico "/Applications/MAMP/bin/favicon.ico"

and comment it out with a hash (#). Save your configuration, then reboot MAMP’s Apache server. You might have to flush your browser’s cache before it recognises your own favicons.

This took way too long to fix, so I hope this helped someone else.