13

How can I install Intl on my XAMPP server on OS X?

I tried modifying my XAMPP>etc>php.ini and uncommenting the line:

;extension=php_intl.dll

and restarting Apache, but it didn't work.

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
Shubham Tiwari
  • 693
  • 1
  • 5
  • 18

3 Answers3

24

Installing "intl" extension on OSX.

  1. Normally, the PHP is automatically installed on OSX. So, if you would like to use the XAMPP, or whatever apache server, you must change the path point to XAMPP. You can check the path by using:

$ which php

You should get

/Applications/XAMPP/xamppfiles/bin/php 

if not, you will get

/usr/bin/php. 

This is OSX' php. So, you have to change it by using:

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

  1. Now, it's time to install intl. Firstly, you need to install icu4c

$ brew install icu4c

It takes a couple of times and returns its path to you, should look something like this:

/usr/local/Cellar/icu4c/x.x.x 
  1. Next, let's install intl by using pecl

$ sudo pecl update-channels

$ sudo pecl install intl

It will prompt you to put the icu4c path. After finish installing icu4c, put the following statement to php.ini

extension=intl.so
  1. Restart apache. and check whether it's neatly installed.

$ php -m | grep intl

should return 'intl'

That's it!

Shubham Tiwari
  • 693
  • 1
  • 5
  • 18
  • 2
    when i run this command sudo pecl install intl it returns this msg No releases available for package "pecl.php.net/intl" install failed – amit gupta Jan 31 '16 at 03:55
  • I had to uninstall (sudo pecl uninstall intl ) first because I had installed it with the wrong path. Works great if I would follow the instructions! – Dan Mar 31 '16 at 15:21
  • Help please. It shows: Channel "pear.phpunit.de" is not responding over http://, failed with message: File http://pear.phpunit.de:80/channel.xml not valid (received: HTTP/1.1 410 Gone ) Trying channel "pear.phpunit.de" over https:// instead Cannot retrieve channel.xml for channel "pear.phpunit.de" (Connection to `pear.phpunit.de:443' failed: ) ..... – bluesky777 Jun 15 '16 at 01:05
  • @amit gupta: Try answer from cweiske at http://stackoverflow.com/questions/35953764/no-releases-available-for-package-pecl-php-net-intl . Worked for me. – SenioreT Aug 05 '16 at 18:24
  • Good solution and description. Thanks – Memariaan May 08 '19 at 22:14
7

On OSX if you have homebrew available and have PHP7:

$ brew install php70-intl // For PHP7.0
$ brew install php71-intl // For PHP7.1

For PHP5.5:

$ brew install php55-intl

Re-open your terminal window to ensure it works right in your session. To see if it loaded via your CLI interpreter:

$ php -m | grep intl

Or:

$ php -i "(command-line 'phpinfo()')" | grep intl

Source: https://daveismyname.blog/blog/install-php-intl-on-mac-using-homebrew

Saravanan Sampathkumar
  • 3,201
  • 1
  • 20
  • 46
HongPong
  • 616
  • 8
  • 14
1

I failed on my XAMPP on Mac with:

$ brew install icu4c

, after which I've got message:

intl ICU version installed on your system is outdated (4.8.1.1) and does not match the ICU data bundled with Symfony (57.1)

I solved my problem by running command to download, unpack, compile and install ICU of required version (you can choose another version here http://site.icu-project.org/download if needed, file should ends with ...src.tgz):

$ curl -sS -o /tmp/icu.tar.gz -L http://download.icu-project.org/files/icu4c/57.1/icu4c-57_1-src.tgz && tar -zxf /tmp/icu.tar.gz -C /tmp && cd /tmp/icu/source && ./configure --prefix=/usr/local && make && sudo make install

than run:

$ sudo pecl install intl

and specified where ICU libraries and headers can be found [DEFAULT] :

/usr/local

then edited 'php.ini' with extension=intl.so and reboot apache.

Checked result with:

<?php
if (extension_loaded('intl')) {
    echo "PHP: " . PHP_VERSION . "<br>\n";
    echo "ICU: " . INTL_ICU_VERSION . "<br>\n";
} else {
    die('OOPS! The intl extension is not enabled!');
}
Amir
  • 8,821
  • 7
  • 44
  • 48
Stan Fad
  • 1,124
  • 12
  • 23