如何在macOS Mojave上启用PHP Intl扩展?

问题描述 投票:0回答:2

我正在尝试在macOS Mojave上安装Magento(2.3.0)。 Magento显示PHP Extension intl.缺失。

我尝试以下解决方法:

  1. 使用cp /etc/php.ini.default php.ini制作了php.ini的副本
  2. 删除了“;”在extension=php_intl.dll之前
  3. 重启Apache sudo apachectl restart

但上面没有解决。

在检查php -v时,我看到以下错误:

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

/usr/lib/php/extensions/no-debug-non-zts-20160303下只有2个文件,即opache.soxdebug.so

如何在我的macOS Mojave上安装或启用“PHP Extension intl”?

php macos php-extension macos-mojave
2个回答
1
投票

这是一个适合我的解决方案:

  1. 找到安装brew list | grep php的所有PHP版本
  2. 删除所有版本的PHP brew remove --ignore-dependencies --force php70 php71 php72(基于您在上面看到的内容)
  3. 安装PHP brew install php72(我选择7.2,7.3尚未被多家供应商支持)
  4. 运行命令which php应该显示已安装的PHP的路径。复制路径。
  5. 更新你的bash_profile vi ~/.bash_profile并将此行添加到文件中:export PATH=/usr/local/php5/bin:$PATH
  6. 保存并运行此source ~/.bash_profile
  7. 检查是否使用php -m | grep intl安装了PHP Intl Extension。如果安装顺利,我们将看到列出的intl。如果没有,则不安装扩展。

我认为从PHP 7(不确定版本),默认情况下扩展是可用的,我们不需要在php.ini文件中明确启用它们。


0
投票

如果您安装了Homebrew的php,将其链接到路径中的目录将解决问题。 brew link --force [email protected]我有同样的问题并修复了它。 Here是我得到详细答案的链接


-1
投票

从链接获得帮助,并能够编译https://donatstudios.com/Install-PHP-Mcrypt-Extension-in-OS-X

接下来我们将下载PHP源代码。验证您正在运行的PHP的确切版本。这可以如下检索。该版本突出显示。

$ 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
© www.soinside.com 2019 - 2024. All rights reserved.