How to enable PHP Intl extension on macOS Mojave?
Asked Answered
L

3

8

I'm trying to install Magento (2.3.0) on macOS Mojave. Magento shows PHP Extension intl. is missing.

I tried the below to resolve:

  1. Made a copy of php.ini using cp /etc/php.ini.default php.ini
  2. Removed ";" before extension=php_intl.dll
  3. Restart Apache sudo apachectl restart

But the above did not resolve.

On checking php -v, i'm seeing the below error:

PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/lib/php/extensions/no-debug-non-zts-20160303/php_intl.dll' - 
dlopen(/usr/lib/php/extensions/no-debug-non-zts-20160303/php_intl.dll, 
0x0009): dlopen(): file not found: /usr/lib/php/extensions/no-debug- 
non-zts-20160303/php_intl.dll in Unknown on line 0
PHP 7.1.19 (cli) (built: Aug 17 2018 20:10:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

There are only 2 files under /usr/lib/php/extensions/no-debug-non-zts-20160303 namely opache.so and xdebug.so

How can i install or enable "PHP Extension intl" on my macOS Mojave?

Laris answered 15/1, 2019 at 20:22 Comment(3)
extension=php_intl.dll should be extension=php_intl.so, because this is not Windows.Whiteheaded
Thanks. Tried that but same issue al-OSX:sbin konathal$ php -i | grep intl PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20160303/php_intl.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20160303/php_intl.so, 0x0009): dlopen(): file not found: /usr/lib/php/extensions/no-debug-non-zts-20160303/php_intl.so in Unknown on line 0Laris
Possible duplicate of Install intl PHP extension OSX High SierraWhiteheaded
L
7

Here's a solution that worked for me:

  1. Find all PHP versions installed brew list | grep php
  2. Remove all versions of PHP brew remove --ignore-dependencies --force php70 php71 php72 (based on what you see above)
  3. Install PHP brew install php72 (i chose 7.2, 7.3 is not supported yet by several vendors)
  4. Run the command which php should show you the path to the installed PHP. Copy the path.
  5. Update your bash_profile vi ~/.bash_profile and add this line to the file: export PATH=/usr/local/php5/bin:$PATH
  6. Save and run this source ~/.bash_profile
  7. Check if PHP Intl Extension is installed using php -m | grep intl. If the installation went well, we will see intl listed. If not the extension is not installed.

I think from PHP 7 (not sure of the version), the extensions are available by default and we need not enable them in php.ini file explicitly.

Laris answered 25/1, 2019 at 16:14 Comment(1)
Helpful answer, but I don't think adding export PATH=/usr/local/php5/bin:$PATH in .bash_profile is necessary? I installed PHP with brew and there is no /usr/local/php5 directory on my machine.Psychologism
R
1

If you installed Homebrew's php, linking it to a directory in your path will fix the issue. brew link --force [email protected] I had the same issue and that fixed it. Here is a link where I got a detailed answer from

Reclaim answered 4/7, 2019 at 8:54 Comment(0)
P
-1

Got help from the link and able to compile https://donatstudios.com/Install-PHP-Mcrypt-Extension-in-OS-X

Next we will download the PHP source. Verify the exact version of PHP you are running. This can be retrieved as follows. The version is highlighted.

$ php --version
PHP 7.1.19 (cli) (built: Aug 17 2018 18:03:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group

Now we move into a working directory and download the source making sure to update the following for the version from above.


$ cd /tmp
$ curl -L http://php.net/get/php-{{php-version}}.tar.bz2/from/this/mirror > php.tar.bz2
$ open php.tar.bz2

Now we will compile and test the extension.

$ cd php-{{php-version}}/ext/{{extension}}
$ phpize
$ ./configure
$ make
$ make test
$ sudo make install

If all that goes well finally we'll need to add the following to our php.ini - I usually add at it at the end of the file.

extension = {{extension}}
.so
You can verify your installation with the following:

$ php --info | grep {{extension}}\\.

Lastly, depending on your setup now you may want to restart apache.

$ sudo apachectl restart
Profile answered 26/1, 2019 at 17:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.