Can't install php Intl extension on MacosX

ICU stands for ICU - International Components for Unicode

Install it with brew

brew update
brew search icu # returns 'icu4c'
brew install icu4c

OR

Install it with pecl

sudo pecl update-channels
sudo pecl install intl

installing intl package on osx


EDIT: after a better look in [email protected] it seems that it is already compiled with 'intl'

php -i | grep intl
... '--enable-intl' ...

So my answer is normally useless for [email protected] (but can be useful in some cases I guess)


I'm facing the same issue today trying to switch from php56 to [email protected].

After lot of digging, here is the workaround.

Make sure to have a clean install of [email protected] and to have it at the current version

php -v
PHP 5.6.35 (cli) (built: Mar 31 2018 20:21:31)

Make also sure to have icu4c

brew update
brew install icu4c

Next, we will install and compile intl manually

cd /usr/local/src/
wget https://pecl.php.net/get/intl-3.0.0.tg
tar zxf intl-3.0.0.tgz
cd intl-3.0.0/
phpize --clean
phpize
./configure    

And here is the trick, edit Makefile

vi Makefile

Modify the line CXXFLAGS as follow

CXXFLAGS = -g -O2 -std=c++11

AND the line CPPFLAGS as follow

CPPFLAGS = -DHAVE_CONFIG_H -DU_USING_ICU_NAMESPACE=1

Next, save, and compile

make
make install

And voila

Installing shared extensions:     /usr/local/Cellar/[email protected]/5.6.35/pecl/20131226/

Don't forget to add extension="intl.so" to your php.ini

vi /usr/local/etc/php/5.6/php.ini

(and to restart apache)

Sources:

  • https://gist.github.com/redefinelab/4188331
  • https://github.com/Homebrew/homebrew-php/commit/d7a3e0b6487780e0d983b35b8f42aad0fd01bf78

download the version of PHP you use in XAMPP from php.net. I am using 7.3. This version worked for me: php-7.3, I’m guessing if you follow the steps it might work for 7.0 or 7.2 as well.

Extract the tar.gz file using (I extracted it inside ~/Downloads/ folder )

tar -xzvf php-7.1.31.tar.gz cd into the extracted folder

cd php-7.1.31 change to subfolder ext/intl

cd ext/intl/ Run these commands to build the extension

/Applications/XAMPP/bin/phpize

./configure --enable-intl --with-php-config=/Applications/XAMPP/bin/php-config --with-icu-dir=/Applications/XAMPP/xamppfiles/

make

sudo make install

you can now delete all files you downloaded and also the extracted folders.

Open /Applications/XAMPP/xamppfiles/etc/php.ini , and add extension=intl.so

That’s it! Restart your Apache using XAMPP GUI and it should work. You have to run these commands each time you install a new version of XAMPP.