Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install intl PHP extension OSX High Sierra

How can I install intl PHP extension in PHP 7.1.7, which is delivered with osx high sierra?

like image 382
Mondy Avatar asked Oct 09 '17 18:10

Mondy


People also ask

What is Intl extension?

The Internationalization extension (Intl) is a wrapper for the ICU library, a set of C/C++ and Java libraries that provide Unicode and Globalization support for software applications. It enables PHP programmers to perform UCA-conformant collation and date/time/number/currency formatting in their scripts.

What are PHP extensions?

php file extension refers to the name of a file with a PHP script or source code that has a ". PHP" extension at the end of it. It's similar to a Word file with a . doc file extension.


2 Answers

So I had the exact same issue. As noted by other folks commenting here, High Sierra comes with PHP 7.1 installed and this PHP version has intl compiled with it

In my case, I followed part of Neodork comment's in the following Valet+ issue:

"Install" PHP 7.1 (so it comes from brew itself, not the one installed by High Sierra)

brew install [email protected]

Upgrade it to latest version

brew upgrade [email protected]

Symlinks for references in Cellar:

brew link --overwrite --force [email protected]

Change PHP path in my bash profile

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile 

Reload your bash profile (you can close the terminal and open it again)

. ~/.bash_profile

Check for Intl

php -m | grep intl

Note: If you come across with warnings like:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php71-intl/intl.so'

Then you have to disable the previous intl:

mv /usr/local/etc/php/7.1/conf.d/ext-intl.ini /usr/local/etc/php/7.1/conf.d/ext-intl.ini.disabled

Hope it helps!

like image 61
Steven667 Avatar answered Sep 20 '22 13:09

Steven667


After the integration from brew/php to brew/core, the intl extension is included by the default installation. I also had the same problem the intl extension wasn't working. The problem I had was the command-line environment was not using the installed version of PHP but the default version from macOS system.

To enable the installed version, you need to do this:

After brew install [email protected]

You need to link the installed PHP version by brew link [email protected]

Then you need to OPEN A NEW TERMINAL to make it effective.
Then double check the PHP binary path, which php

make sure it's /usr/local/bin/php instead of /usr/bin/php

Then check if the intl extension is enabled, php -m | grep intl

It works for me.

like image 33
jallen0927 Avatar answered Sep 23 '22 13:09

jallen0927