Categories
OSX Web Development

Install ext-intl on Mac OSX using homebrew and XAMPP

This was a painful process for me, it took quite a while to figure out why such a simple implementation when using ubuntu, can be so much work in a Mac.

We can’t just install the extension with apt-get like ubuntu, and its not already waiting to be uncommented like in windows, we have to install the the shared object intl.so our selves.  and the easiest way of doing this is by using homebrew and pecl.

Step 1 – Install Homebrew

Homebrew Website: http://brew.sh

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Step 2 – Install Install icu4c

ICU4C Website: http://site.icu-project.org

brew install icu4c

Step 3 – Install Autoconf

More about Autoconf: http://brewformulas.org/Autoconf

brew install autoconf

Step 4 – Install Intl via PECL

PECL Website: https://pecl.php.net

sudo pecl update-channels
sudo pecl install intl

Step 5 – Enable intl.so in php.ini

Go to your php.ini file and at the end, add the following line:

extension=intl.so

This will enable the extension that we have just installed.

Step 6 – Restart your server

Use XAMPP to restart your server, this will reload the php.ini file with the new configuration.

Step 7 – Check it worked!

You can check if Intl was installed successfully by using the following command to list the loaded php modules.  If ‘intl‘ it is listed then it has been successfully loaded.

php -m

I am running php via Terminal and it didn’t work?

One common problem is that terminal is using the the wrong version of php, sometimes a system default is loaded rather than the php version you are using in XAMPP.  First lets check what version we are using:

which php

If you are using XAMPP correctly it should return:

  • /Applications/XAMPP/xamppfiles/bin/php 

If not and it loads from:

  • /usr/bin/php

Then we can temporarily change the path of the default php version to the XAMPP version by running the following in terminal:

PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}"

Now if you run “which php” in terminal again you should get the correct path.

 

 

Leave a Reply