Install intl PHP extension OSX High Sierra
Asked Answered
O

11

33

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

Outguard answered 9/10, 2017 at 18:38 Comment(0)
A
61

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!

Alwyn answered 10/7, 2018 at 21:20 Comment(7)
Very helpful! Thanks!Centiare
brew link --overwrite --force [email protected] // Linking /usr/local/Cellar/[email protected]/7.1.25... // Error: Could not symlink sbin/php-fpm // /usr/local/sbin is not writable.Tarnopol
@NathanJ.Brauer that's a good one. Seems people have been having issues with that also. Check if the directory exists. If an ls -la /usr/local/sbin/ pops something, then check for the permissions for it. Otherwise, you'll have to create it and adjust the right permissions with something like sudo mkdir /usr/local/sbin && sudo chown -R `whoami`:admin /usr/local/sbin The information was extracted from here: github.com/Homebrew/homebrew-php/issues/4527Alwyn
@NathanJ.Brauer I got the same error. I exported the new path anyway, opened a new terminal and which php pointed to /usr/local/opt/[email protected]/bin/php. Check if it works for youPlatitudinize
For those of you similarly brewtarded as I am, the referenced 7.1 above should be updated to reference your required version. As of right now, Brew fails to find a 7.1 reference, because 7.4 is the one I needed. Double check your needed version before you proceed, unlike my last hour... ;)Krauss
Thanks mate. Been looking for this since 3hrs now.Owenism
I had the same issue - Error: Could not symlink sbin/php-fpm // /usr/local/sbin is not writable. I did sudo mkdir /usr/local/sbin && sudo chown -R whoami:admin /usr/local/sbin and then need to source .bash_profile or open another terminal to see the correct php install path.Prejudice
T
19

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.

Tether answered 4/7, 2018 at 20:14 Comment(1)
i tried many solutions for now but this one works for me thanks alot.Tranquillize
C
11

open a terminal then type:

brew search intl

you should be able to see php71-intl, then run

brew install homebrew/php/php71-intl

then restart apache

sudo apachectl restart

then type:

php -i | grep intl

you should be able to see something like this:

Additional .ini files parsed => /usr/local/etc/php/7.1/conf.d/ext-intl.ini
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0

Enjoy!

Cherenkov answered 25/12, 2017 at 12:11 Comment(7)
The homebrew/php tab has been deprecated as of April 1st, 2018. The new way PHP and its extensions are delivered now is... a mess. Some extensions are bundled, some aren't.Charo
When I brew search php71-intl I get no formula found for php71-intl and then I get list of closed PRs. I can't find a way to install the intl package with homebrew. I have the homebrew/php and homebrew/core taps even though the php tap is deprecated. If I try to brew install php71-intl I get errors saying formula not available, not found and not found in tapsNancinancie
The person who deprecated php tap is a full ***. Everything broke after latest sierra update and brew upgrade. If you deprecate something in favor of something else, CHECK if that something else even works... If someone managed to get intl up and running again, please reply. I tried install through pecl but that just throws even more errors.Staphyloplasty
php-intl is now bundled with the php formulae in Homebrew. Simply uninstall your current php version and reinstall the homebrew/core php : brew install php71 --with-pearPhidippides
$ brew uninstall php71 and then brew install php71 --with-pearParnas
php has moved to homebrew/core. The formula is renamed to [email protected]. It includes intl by default, there is no need to load or install the extension manually.Rainbow
@Parnas Its working but im getting bunch of warnings about PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php71-intl/intl.so' - dlopen(/usr/local/opt/php71-intl/intl.so, 9): Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.60.dylib. Any idea?Ogg
C
7

I'm running the brew 1.6.2, on OS High Sierra. The intl extension is not available in brew packages so far.

The @Mondy solution worked fine for me. After run the

curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1

The packages will be available in /usr/local/php5 or /usr/local/php5-7.0.27-20180201-135220.

So in your /usr/local/etc/php/7.0/php.ini you can place the following lines to enable the intl extension:

[intl]
extension="/usr/local/php5/lib/php/extensions/no-debug-non-zts-20151012/intl.so"

In my case I prefered to create a file 'ext-intl.ini' in /usr/local/etc/php/7.0/conf.d/, just for a better organization.

Cyclopedia answered 26/4, 2018 at 8:17 Comment(4)
where is place intl.so?Soane
I was able to install on macox high sierra. but had issue with it first PHP Warning: PHP Startup: intl: Unable to initialize module Module compiled with module API=20170718 PHP compiled with module API=20160303 These options need to match in Unknown on line 0 Pasto
This worked for me! I used extension="/usr/local/php5-7.1.21-20180903-114446/lib/php/extensions/no-debug-non-zts-20160303/intl.so". You will find the exact path in the output of the install.Rothwell
This worked for me too, I just downloaded directly the needed file from https://s3-eu-west-1.amazonaws.com/php-osx.liip.ch/install/5.6-10.10/frontenddev/5.6-10.10-frontenddev-5.6.36-20180703-123509.tar.bz2 (which for php 5.6 in my case), and copied intl.so to xamppfiles/lib and updated php.ini with the corresponding link.Fearless
I
7

try this on Mac

php -v
sudo port install php7*-intl

More information

You can find port packages by this page https://www.macports.org/ports.php?by=name&substr=intl

And you can install port through these steps: https://guide.macports.org/chunked/installing.macports.html

curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.5.4.tar.bz2
tar xf MacPorts-2.5.4.tar.bz2
cd MacPorts-2.5.4/
./configure
make
sudo make install

And change ~/.bash_profile

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

If there is error, check following steps:

check port

sudo port list
sudo port selfupdate
sudo port search --name --glob 'php*'
sudo port install php**-intl

This page has more info about port usage: https://guide.macports.org/chunked/using.html

Inherit answered 5/8, 2019 at 13:59 Comment(1)
Interesting concept, but the MacPorts project is an absolute mess, there isn't even a working version for macOs Catalina, which is over 1 year old now and installed on literally every mac in the worldNolannolana
T
4

In addition to what L. Grolleau says (run brew install php71-intl), paste the int.so path to the /php.ini at the end of the file:

extension=/usr/local/Cellar/php71-intl/7.1.11_20/intl.so
Toadfish answered 17/11, 2017 at 21:23 Comment(0)
O
3

I find a solution.

curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1

Then I copied intl.so from the installation to my extension directory, which is defined into my php.ini.

Outguard answered 9/10, 2017 at 19:40 Comment(3)
Can you go a little more into detail? Where is the intl.so located after executing the above command.Freya
php -i | grep extensionLinea
Actually when trying sudo cp /usr/local/php5-7.1.13-20180201-134129/lib/php/extensions/no-debug-non-zts-20160303/intl.so /usr/lib/php/extensions/no-debug-non-zts-20160303/intl.so I get Operation not permitted - going to try switching the version of php rather than just the extension. more info here php-osx.liip.ch and websitebeaver.com/…Linea
S
1

I have managed to work this out.

First uninstall any php packages you have completely with brew, then run the brew update and brew doctor commands.

Now install with brew install [email protected] (changed the version as needed) intl is included in the build for all php-formulae.

To confirm it is working run php -m | grep intl. You will see the intl extension is included. If not check the php.ini file and make sure the extension is being loaded.

Scheck answered 7/4, 2018 at 8:1 Comment(1)
You will not need to check the php.ini, as the extension is built in.Rainbow
A
0

Remove the following file with

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

Worked for me, thanks to homebrew-core Issue

Aubade answered 11/9, 2018 at 23:51 Comment(0)
P
0

I installed php7.2 with brew and linked with that version on Mac, but cannot see even the version number 7.2 in phpinfo(). It always showed the last version(7.1) even though uninstall with brew, so the intl extension. I found we have to modify httpd.conf file(in my case in /etc/apache2/httpd.conf), in that file you can find the

LoadModule php7_module libexec/apache2/libphp7.so

in that line you have to override with your new php72 path: in my case it was

 LoadModule php7_module /usr/local/Cellar/[email protected]/7.2.31_1/lib/httpd/modules/libphp7.so

And restart apache, it works fine.

Pneumoconiosis answered 27/6, 2020 at 10:52 Comment(0)
T
-6

try this

brew install homebrew/php/php71-intl
Tullius answered 2/2, 2018 at 21:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.