安装国际 PHP 扩展 OSX High Sierra

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46652968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 03:14:40  来源:igfitidea点击:

Install intl PHP extension OSX High Sierra

phpintlmacos-high-sierra

提问by Mondy

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

如何在 osx high sierra 随附的 PHP 7.1.7 中安装 intl PHP 扩展?

回答by Steven667

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

所以我遇到了完全相同的问题。正如其他人在此处评论所指出的,High Sierra 安装了 PHP 7.1,并且这个 PHP 版本已经用它编译了 intl

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

就我而言,我在以下Valet+ 问题中关注了 Neodork 的部分评论:

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

“安装” PHP 7.1(所以它来自 brew 本身,而不是 High Sierra 安装的那个)

brew install [email protected]

brew install [email protected]

Upgrade it to latest version

升级到最新版本

brew upgrade [email protected]

brew upgrade [email protected]

Symlinks for references in Cellar:

Cellar 中参考的符号链接:

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

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

Change PHP path in my bash profile

在我的 bash 配置文件中更改 PHP 路径

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 配置文件(您可以关闭终端并再次打开它)

. ~/.bash_profile

. ~/.bash_profile

Check for Intl

检查国际

php -m | grep 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'

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

Then you have to disable the previous intl:

然后你必须禁用之前的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

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!

希望能帮助到你!

回答by jallen0927

After the integration from brew/phpto brew/core, the intlextension is included by the default installation. I also had the same problem the intlextension 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.

从 集成brew/php到 后brew/coreintl默认安装中包含扩展。我也遇到了同样的问题,intl扩展程序不起作用。我遇到的问题是命令行环境没有使用已安装的 PHP 版本,而是使用 macOS 系统的默认版本。

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

要启用已安装的版本,您需要执行以下操作:

After brew install [email protected]

brew install [email protected]

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

您需要通过以下方式链接已安装的 PHP 版本 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

然后您需要打开一个新的终端以使其有效。
然后仔细检查 PHP 二进制路径, which php

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

确保它 /usr/local/bin/php 不是 /usr/bin/php

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

然后检查是否启用了 intl 扩展, php -m | grep intl

It works for me.

这个对我有用。

回答by Mhyk Manasan

open a terminal then type:

打开一个终端然后输入:

brew search intl

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

你应该可以看到php71-intl,然后运行

brew install homebrew/php/php71-intl

then restart apache

然后重启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!

享受!

回答by Lipdk

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

我在 OS High Sierra 上运行 brew 1.6.2。到目前为止, brew 包中没有 intl 扩展名。

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

@Mondy 解决方案对我来说效果很好。运行后

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.

这些包将在 /usr/local/php5 或 /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:

所以在你的 /usr/local/etc/php/7.0/php.ini 你可以放置以下几行来启用 intl 扩展:

[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.

就我而言,我更喜欢在 /usr/local/etc/php/7.0/conf.d/ 中创建一个文件“ext-intl.ini”,只是为了更好的组织。

回答by Gustavo A Garcia

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

除了L. Grolleau 所说的(run brew install php71-intl),将int.so路径粘贴到/php.ini文件末尾:

extension=/usr/local/Cellar/php71-intl/7.1.11_20/intl.so

回答by Mondy

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.

然后我将 intl.so 从安装复制到我的扩展目录中,该目录定义在我的 php.ini 中。

回答by Shark Deng

try this on Mac

在 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

您可以通过此页面https://www.macports.org/ports.php?by=name&substr=intl找到端口包

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

您可以port通过以下步骤安装: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

并更改 ~/.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

此页面包含有关端口使用的更多信息:https: //guide.macports.org/chunked/using.html

回答by Lindsay

I have managed to work this out.

我已经设法解决了这个问题。

First uninstall any php packages you have completely with brew, then run the brew updateand brew doctorcommands.

首先使用 brew 完全卸载您拥有的任何 php 包,然后运行brew updatebrew doctor命令。

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

现在安装brew install [email protected](根据需要更改版本)intl 包含在所有 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.

确认它正在运行运行php -m | grep intl。您将看到包含 intl 扩展名。如果没有,请检查 php.ini 文件并确保正在加载扩展。

回答by Nicolas

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

为我工作,感谢homebrew-core 问题

回答by L. Grolleau

Try this :

尝试这个 :

brew install php71-intl