14

I'm following this link to install this PHP extension but I'm stuck in the middle.
When I try to run this command pecl install intl I get this message:

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

And I don't know where the ICU libraries are located.
If I press Enter I get this error:

configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
ERROR: `/private/tmp/pear/install/intl/configure --with-php-config=/usr/bin/php-config --with-icu-dir=DEFAULT' failed

How can I locate the correct path of ICU libraries ? I'm using High Sierra and MAMP with PHP version 7.1

Community
  • 1
  • 1
SlimenTN
  • 3,383
  • 7
  • 31
  • 78
  • It might work using `brew` like described in the answer to this question: https://stackoverflow.com/questions/42085083/install-php-intl-extension-on-macos/ – Kilian Obermeier Jan 07 '18 at 09:32
  • I have tried this but still not working, you see I was trying to install `PayumBundle` for symfony and it requires this extension – SlimenTN Jan 07 '18 at 09:36

3 Answers3

8

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

Cedric
  • 5,135
  • 11
  • 42
  • 61
  • 1
    Thanks for your response but it still ask me to enter icu path whenever I try to use `sudo pecl install intl` – SlimenTN Jan 09 '18 at 08:21
  • What about the first method, with brew ? – Cedric Jan 09 '18 at 08:38
  • https://stackoverflow.com/questions/13726386/how-to-point-configure-down-the-right-path-to-icu – Cedric Jan 09 '18 at 08:40
  • 1
    Yes I found the path from the link you provide, Thanks a lot :) – SlimenTN Jan 09 '18 at 09:14
  • I have come across the same. Brew install icu4c seems to work but sudo pecl install intl fails. It is trying to install in the default directory. Get ERROR: `make' failed. Still getting 'Install and enable the intl extension (used for validators).' – Daniel Mar 28 '18 at 15:53
  • Perfect. Don't hesitate to upvote if the answer has helped you. – Cedric Mar 28 '18 at 16:14
  • @dan Installing `php56-intl` for `php 7.1`? If I try to install php56-intl I get this error : `Error: No formulae found in taps.` – Szekelygobe Oct 08 '18 at 19:04
  • 3
    `sudo pecl install intl` .command returns `configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works. ERROR: "/private/tmp/pear/install/intl/configure --with-php-config=/usr/local/bin/php-config --with-icu-dir=DEFAULT' failed"` – mapmalith May 29 '19 at 05:46
  • 4
    `sudo pecl install intl` for `php 7.3` returning error: `In file included from /private/tmp/pear/temp/intl/php_intl.h:34: /private/tmp/pear/temp/intl/intl_error.h:24:10: fatal error: 'ext/standard/php_smart_str.h' file not found #include ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. make: *** [php_intl.lo] Error 1 ERROR: `make' failed` – Shankar Jun 20 '20 at 16:07
  • `make` is still failing on me just like for @Shankar. Were you able to solve it mate? – Fr0zenFyr Oct 23 '20 at 09:15
5

EDIT: after a better look in php@5.6 it seems that it is already compiled with 'intl'

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

So my answer is normally useless for php@5.6 (but can be useful in some cases I guess)


I'm facing the same issue today trying to switch from php56 to php@5.6.

After lot of digging, here is the workaround.

Make sure to have a clean install of php@5.6 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/php@5.6/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:

Cédric
  • 420
  • 4
  • 8
4

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.

sonam
  • 41
  • 4