This is instructions on how to compile and install the intl extension on Mac OS X (10.7+), along with command-line tools, and ICU. Everything will be done through the terminal, except installation of Xcode and the command-line tools.
You might have experienced this issue “Fatal error: Class ‘Locale’ not found in /path/to/file.php”, which means that you need to install the intl module.
Tested from MAMP 2.0.2/PHP 5.3.6 up to MAMP 3.6/PHP 5.6.10.
I assume that you already have MAMP installed. I am using MAMP 3.6 with PHP 5.6.10. You should change the paths throughout the post, to which ever versions of PHP and MAMP you are using. Usually it will just involve changing php5.6.10 to whatever php version you are using.
Xcode is installed, and also that the command line tools has been installed (Xcode > Preferences > Downloads).
# cd ~/downloads # curl -O -L http://php.net/get/php-5.6.10.tar.gz/from/this/mirror > php-5.6.10.tar.gz # tar xzvf php-5.6.10.tar.gz # mkdir /Applications/MAMP/bin/php/php5.6.10/include # mv php-5.6.10 /Applications/MAMP/bin/php/php5.6.10/include/php # cd /Applications/MAMP/bin/php/php5.6.10/include/php # ./configure --without-iconv
Using php 5.4.4 since that’s the latest in 2.1.2
Before we can install the module, you will need to have the source code at hand (the PHP header files), so pecl (and phpize) can compile the extension. Download
MAMP_components_2.1.2.zip to your Downloads folder, and extract it. If you are using another version of MAMP, take a look here. Note: If you can’t find the MAMP components, or just don’t want to download the full package (it is unnecessary if you only need to install this extension), just download the appropriate source file from php.net. The MAMP components image is only infrequently updated, and probably is out of date.
# cd ~/downloads/MAMP_components_2.1.2/ # tar xzvf php-5.4.4.tar.gz # mkdir /Applications/MAMP/bin/php/php5.4.4/include # mv php-5.4.4 /Applications/MAMP/bin/php/php5.4.4/include/php # cd /Applications/MAMP/bin/php/php5.4.4/include/php # ./configure
# cd ~/downloads # curl -O http://download.icu-project.org/files/icu4c/56.1/icu4c-56_1-src.tgz # tar xzvf icu4c-56_1-src.tgz # cd icu/source # ./runConfigureICU MacOSX ; make ; sudo make install
Edit: I experienced the following error during make with 10.9 Mavericks:
ld: 304 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1
This issue is patched in the 52.1 version of ICU (the above has been updated, previous version was 22.214.171.124).
I had an issue that phpize could not find the autoconf command. So I installed it manually (this was version 2.69, you should change the path to the version you have downloaded).
# cd ~/downloads # curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz # tar xzvf autoconf-latest.tar.gz # cd autoconf-2.69 # ./configure ; make ; sudo make install
Now that the ICU and autoconf is in place, we will need to download, phpize, compile, and install the intl extension.
# sudo /Applications/MAMP/bin/php/php5.6.10/bin/pecl i intl
/usr/local when you are prompted: Specify where ICU libraries and headers can be found [DEFAULT] :
When the intl extension has been installed, you enable it in PHP by doing this:
# echo "extension=intl.so" >> /Applications/MAMP/bin/php/php5.6.10/conf/php.ini
And that’s the end of it. Restart MAMP and you are ready to go!