Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Install the PHP INTL extension on a Mac
The INTL extension may be included in PHP 5.4, PHP 5.3 is still the main PHP version installed on many production servers. Here is how you install it on a Mac.
Get ICU from 
http://site.icu-project.org/download
At the time of this writing, I downloaded the 
icu4c-49_1_2-src.tgz package on
http://site.icu-project.org/download/49
Unzip the file. Open a new bash window and go to the /source folder of the unzipped file.
In Terminal, type :
./runConfigureICU MacOSX
make
sudo make install
sudo pecl install intl
You now have the INTL extension on your hard drive, but you have to copy it in your PHP extensions folder. Since I’m using MAMP, i’m copying it in the MAMP extension folder (which is not the same folder as the CLI PHP extension folder). In Terminal, type :
cp /usr/lib/php/extensions/no-debug-non-zts-20090626/intl.so /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/intl.so
Edit your php.ini file. In my case, it is located in /Applications/MAMP/bin/php/php5.3.6/conf/php.ini. Add this line to the extensions section :
extension=intl.so
Restart MAMP.
Enjoy !

When I run "sudo pecl install intl" i got this error:

include <php.h>

     ^

1 error generated.
make: *** [php_intl.lo] Error 1
ERROR: `make' failed

Did you get this same error? Do you know how can I resolve?

You find the solution ??

@marcomafessolli I have the same problem

👌 I resolved my problem via xcode-select --install

devTechi commented Dec 9, 2016

@athlonUA Thank you very much. Got me further.

I’m having trouble executing the command sudo pecl install intl. I get the following message:

WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
Cannot install, php_dir for channel "pecl.php.net" is not writeable by the current user

I tried this solution http://stackoverflow.com/questions/11597944/install-oauth-pecl-error-cannot-install-php-dir-for-channel-pecl-php-net-is/11813232, but when I run pecl config-get php_dir it gives me the following directory that doesn’t seem to exist:

/usr/lib/php/pear

So obviously trying to change ownership of said directory doesn’t work. Did anybody else run into this issue?

I'm having issues at

sudo pecl install intl

during the process, i get an error:

/usr/local/include/unicode/unistr.h:3025:7: error: delegating constructors are permitted only in C++11
UnicodeString(ConstChar16Ptr(text)) {}
^~~~~~~~~~~~~
/usr/local/include/unicode/unistr.h:3087:7: error: delegating constructors are permitted only in C++11
UnicodeString(ConstChar16Ptr(text), length) {}
^~~~~~~~~~~~~
/usr/local/include/unicode/unistr.h:3180:7: error: delegating constructors are permitted only in C++11
UnicodeString(Char16Ptr(buffer), buffLength, buffCapacity) {}
^~~~~~~~~~~~~

anyone have similar issues?

torleif commented May 9, 2017

@kailasnarendran I'm having the same issue. No fixes yet.

kailasnarendran commented May 9, 2017

I just figured out the solution to the problem with "delegating constructors are permitted only in C++11"

It looks like the latest version of ICU uses the C++11 features that are not available in osx sierra.

I had to download 58 to get this to work.

http://site.icu-project.org/download/58

to get intl to successfully install I had to disable SIP (http://www.macworld.com/article/2986118/security/how-to-modify-system-integrity-protection-in-el-capitan.html)

Daou commented May 11, 2017

I can verify @kailasnarendran, using the 58 works. 59 doesn't...

giordhano commented Jun 14, 2017

On macos Captain
We need specified -std=c++11 for CXXFLAGS in the makefile.

First

Download the ICU 59.1 source, and edit source/runConfigureICU add -std=c++11 in RELEASE_CXXFLAGS line

MacOSX)
        THE_OS="MacOS X (Darwin)"
        THE_COMP="the default"
        RELEASE_CFLAGS='-O2'
        RELEASE_CXXFLAGS='-O2 -std=c++11' 
        DEBUG_CFLAGS='-g -O0' 
        DEBUG_CXXFLAGS='-g -O0'
        ;;

run
./runConfigureICU MacOSX
make
make install

Second: install AutoConf

cd ~ && curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
tar -zxvf autoconf-latest.tar.gz
cd autoconf-2.69
./configure
make
sudo make install

Third:

Download intl-3.0.0 code (https://pecl.php.net/get/intl-3.0.0.tgz)

cd intl-3.0.0/intl-3.0.0
run
phpize --clean
phpize
./configure

Here, edit Makefile search CXXFLAGS line and add -std=c++11


CXX = g++
CXXFLAGS = -g -O2 -std=c++11
CXXFLAGS_CLEAN = $(CXXFLAGS)

Save changes and run
make
make install

This works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment