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!