Mac OS: Intl extension is not loaded
Asked Answered
N

6

18
  • macOS Mojave 10.14.3
  • PHP 7.1.23
  • Prestashop 1.7.5.1

I tried to install PHP intl extension on my local server in order to use Prestashop.

I added extension=php_intl.so to etc/php.ini

When I try to install Prestashop I get Intl extension is not loaded.

$ php -m | grep intl

When I do $ php -m | grep intl, I get:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20160303/php_intl.so' - d lopen(/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20160303/php_intl.so' - dlopen (/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0 intl

It seems that the file php_intl.so doesn't exist.

$ sudo pecl install intl

I also tried $ sudo pecl install intland I get:

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

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

I also tried $ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1 and it doesn't create the intl.so file.


How can I solve this problem?

Nightie answered 22/3, 2019 at 14:1 Comment(6)
https://mcmap.net/q/439526/-install-intl-php-extension-osx-high-sierraBritishism
Possible duplicate of Install intl PHP extension OSX High SierraVaulting
did you see this thread : #54206786Corpuz
None of these solutions work for me since brew install php71-intl is not available anymore and curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1 doens't create the intl.so fileNightie
Did you try brew install icu4c before the sudo pecl install intl?Paltry
@SiadArdroumli confirm that, didn't solve the problem, because still get this after sudo pecl install intl: 2 warnings and 1 error generated. make: *** [php_intl.lo] Error 1 ERROR: `make' failedAcescent
V
33

Brew's PHP 7.1, 7.2 and 7.3 all have INTL enabled by default.


Most probably, you're just using your Mac OS' bundles version of PHP.

Run

ls -l $(which php)

to find out where the current PHP binary is located and whether it is symlinked to a Brew installation or not. In my case, for example:

lrwxr-xr-x 1 27 May 23 16:30 /usr/local/bin/php -> ../Cellar/php/7.3.5/bin/php

Meaning that my php is linked to Brew's 7.3.5 version.

If you are NOT using Brew's PHP, you'll see something like

-rwxr-xr-x 1 11169664 Mar 21 07:09 /usr/bin/php

Installing PHP through Brew

Find out whether you've already installed PHP:

brew list | grep php

If there is any output, and your version of PHP is present, go to step 2, or use step 1 to update PHP to the latest version.

1. Install Homebrew's PHP

brew install [email protected]

(or 7.2, 7.1). If Brew complains about not being able to find a formula, you might have messed with taps. Instead of [email protected], you could try to supply the full path to the current php formula:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/php.rb

Still not working, check whether you are running a recent version of Homebrew brew --version.

Homebrew 2.1.3-31-geaf2370
Homebrew/homebrew-core (git revision fd1ef; last commit 2019-05-25)
Homebrew/homebrew-cask (git revision 16d50; last commit 2019-05-26)

2. Link Homebrew's PHP

Now, to have php 'in your path', there are two options.

a) Either homebrew's version must be linked from its install location (/usr/local/bin/Cellar/php....) to a directory in your path (e.g., /usr/local/bin). To do this, run:

brew link --force [email protected]

If you are not able to link, this is typically caused by set permissions or System Integrity Protection. In the first case, try sudo chown "$USER":admin /usr/local/bin/php.

b) Or, add the /usr/local/opt/[email protected] directory (opt-prefix) to your $PATH variable. E.g., for Bash:

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

3. Validate installation

ls -l $(which php)

should show that php is linked to a Homebrew PHP installation in /usr/local/bin/Cellar.

php -v

should show the recently installed version of PHP. Try to restart your terminal if that's not the case.

php -i | grep -i intl

should show some information about the current install of intl.

If you're using webservers and/or PHP FPM, this is the time to restart those services. (Or restart your system, if you don't know how to do that and cannot figure out).

Possible issues

If you still get warnings about missing extensions (Unable to load dynamic library, etc.), then your php.ini is messed up.

Find the current location of php's ini

$ php -i | grep \.ini

Configuration File (php.ini) Path => /usr/local/etc/php/7.3
Loaded Configuration File => /usr/local/etc/php/7.3/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/7.3/conf.d
Additional .ini files parsed => /usr/local/etc/php/7.3/conf.d/ext-opcache.ini
....

Edit /usr/local/etc/php/7.3/php.ini and find the offending extension load (e.g., extension="myext.so"). Comment out those that cannot be found.

Homebrew permissions

Some argue that it's a good idea to chown /usr/local.

sudo chown -R "$USER":admin /usr/local

This will make installing things here, by hand and through Homebrew, a lot easier, but also a bit less secure too, since non-root processes are now allowed to write here too.

Your web-application is using a different version of PHP.

Make sure that it doesn't... The configuration of this depends on the used webserver. A first step would be to output the current PHP configuration in your web-application with <?php phpinfo();.

This explains steps for Apache.

Another way to get a webserver + PHP stack running quicly is using Laravel Valet.

Installing additional extensions

To install additional PHP extensions, use PEAR.

pear -V should output the current PEAR and PHP version.

PEAR Version: 1.10.9
PHP Version: 7.3.5
Zend Engine Version: 3.3.5

Now, to install an extension, for example, PHP's yaml extension:

pear install yaml
Vivyan answered 26/5, 2019 at 7:15 Comment(5)
Thank you! Add this to your answer please. It was my issue after installing brew php I should also rewrite my PATH variables to point to new php. echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile source ~/.bash_profileAcescent
@Volodymyr, that's indeed an option to get PHP in your path, the other being brew link --force [email protected]. I will mention it though!Vivyan
Very detailed. Thank you.Hydr
I have been trying for hours to debug this issue. Nothing was working and nothing made sense. Tried multiple stack answers which all came up empty, until I landed here. Thanks so much for the answer, you're my new hero. Very, very detailed and covers all bases!Dextrality
During the brew install [email protected] step I got "An unexpected error occurred during the brew link step..." This answer resolved that issue: github.com/httpie/httpie/issues/645#issuecomment-456902997Gambrinus
T
1

I have seen a lot of answers about this problem and anyone helped me, but the last (of course). This is for XAMPP´s use.

Xcode is needed. Download the version of php you use in xampp from php.net. Extract it and open the extracted folder in a terminal using cd. Change to subfolder 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 (password required)

Delete all files you downloaded and also the extracted folders. Add to php.ini file in xampp/etc folder line

extension="intl.so"

Original link: https://community.apachefriends.org/viewtopic.php?p=255061&sid=27afc55649dfe6ea7b0824cb0bb8486b

Trilateral answered 3/3, 2020 at 10:31 Comment(0)
R
0

Since php 7 it's not necessary load the extension php_intl.so, what do you need to do?, edit your php.ini and delete or comment the line that is loading the extension php_intl.so, after this reload your apache and try again.

Ragen answered 22/3, 2019 at 16:31 Comment(2)
I tried to do this but Prestashop doesn't detect intlNightie
and are you sure that prestashop is working with the same php.ini that you configured?, create a phpinfo() in the same path of the prestashop install and check the information loaded, this screenshot shows how intl is enabled: i.postimg.cc/B4xNQ5VL/image.pngRagen
P
0

There might be an issue with brew

You could try to use this as mentioned there:

brew tap kyslik/homebrew-php

brew install kyslik/php/php71-intl

Paltry answered 25/5, 2019 at 21:12 Comment(1)
There is no more such thing as brew php on macOS Mojave 10.14.3. Instead there is 'native' PHP 7.1.23 without intl.so extension. Only output from what you suggesting for me is "Error: Invalid formula: /usr/local/Homebrew/Library/Taps/kyslik/homebrew-php/Formula/php54-intl.rb php54-intl: "cxx11" is not a recognized standard Error: Cannot tap kyslik/php: invalid syntax in tap!"Acescent
C
0

i tried all but intl not working in mac so please uninstall xampp and install mamp it will work

Conure answered 17/9, 2019 at 9:17 Comment(0)
C
0

So, on Pecl Official site ( https://pecl.php.net/package/intl ), it's clear that Intl package is not maintained anymore and has been superseded. Since PHP 5.3.0 you don't need to use Pecl to install intl extension, it's bundled with PHP.

But, it's missing on native instalation of PHP 7.1.24 on Mac OS Mojave.

if you wanna use only native apache and php pre-installed instead of using homebrew, do this:

Download PHP 7.1 from php.net, install XCode Command Line Tools, ICU (http://site.icu-project.org/), Autoconf, reinstall the developer tools header files, and finally install Intl extension using phpize.

Important: you'll have to disable SIP.

Cudgel answered 27/9, 2019 at 13:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.