2
votes

How can I install or enable the PHP Pecl Intl extension in my PHP environment?

I've got a stock PHP configuration that came bundled with Mac OS X Snow Leopard. Installing libicu from source and than $pecl install intl results in the following error:

 /private/tmp/pear/temp/intl/collator/collator_class.c:92: error: duplicate 'static'
 /private/tmp/pear/temp/intl/collator/collator_class.c:96: error: duplicate 'static'
 /private/tmp/pear/temp/intl/collator/collator_class.c:101: error: duplicate 'static'
 /private/tmp/pear/temp/intl/collator/collator_class.c:107: error: duplicate 'static'
 make: *** [collator/collator_class.lo] Error 1
 ERROR: `make' failed

Any help is really appreciated!

4
do you want to uninstall first before install?ajreal
If you mean uninstall my complete PHP environment, than I'd rather not. I'm in the middle of a project that is far to big to take the risk of having to install PHP.Marijn Huizendveld
@ajreal, That's not possible. I don't have a PECL install for Intl. Just to be sure I tried pecl uninstall intl but it told me that was not possible since it's not installed to begin with. The problem seems to be rooted in the fact that the source is bundled with my PHP distribution but that it's not enabled.Marijn Huizendveld

4 Answers

8
votes

Here's what I did in OSX 10.9 Mavericks:

  1. Install some dependencies with Homebrew:

    $ brew install autoconf
    $ brew install icu4s
    $ brew link --force icu4s
    
  2. Install and verify Pear/PECL (instructions from http://techtastico.com/post/como-instalar-pear-y-pecl-en-os-x-mavericks/):

    $ curl -O http://pear.php.net/go-pear.phar
    $ sudo php -d detect_unicode=0 go-pear.phar
      [ Select 1 and enter /usr/local/pear ]
      [ Select 4 and enter /usr/local/bin ]
      [ Press return ]
    $ pear version
    
  3. Install PECL intl:

    $ sudo pecl install intl
    $ sudo cp /private/etc/php.ini{.default,}
    $ sudo chmod 644 /private/etc/php.ini
    $ echo extension=intl.so >> /private/etc/php.ini
    
3
votes

For the time being I've recompiled my PHP installation. I've created a gist with my configure string which I'll keep updating.

update

liip have created a nice binary that circumvents all these troubles. It is based on the original entropy.ch binary, I recomend using it for PHP development on a Mac.

1
votes

Better late than never, but if you are like me and installed PHP directly from php.net (instead of using something like Homebrew or Port, then you can simply follow the following link to install Pear and PECL:

http://akrabat.com/php/setting-up-php-mysql-on-os-x-10-7-lion/

It worked fine for me.

1
votes

on my Mac I installed a php version with pear using brew. This solved all my issues as the default osX php didn't work for me after trying many different ways. You can try without installing php/pear if you have already done so.

You need Homebrew http://brew.sh/

Install PHP

brew install php56 --with-pear or brew install php56 pear

Install autoconf

brew install autoconf

Install icu4c

brew install icu4c

Creates the symlinks

brew link --force icu4c

Install intl with (pearl) pecl

sudo pecl install intl

Homebrew should enable intl and symlink all the right versions to their respective commands.