在 Mac 上的 XAMPP 上安装 PHP 国际化扩展 (Intl)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34597100/
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
Install PHP Internationalization extension (Intl) on XAMPP on Mac
提问by Shubham Tiwari
How can I install Intl on my XAMPP server on OS X?
如何在 OS X 上的 XAMPP 服务器上安装 Intl?
I tried modifying my XAMPP>etc>php.iniand uncommenting the line:
我尝试修改我的XAMPP>etc>php.ini并取消注释该行:
;extension=php_intl.dll
and restarting Apache, but it didn't work.
并重新启动Apache,但它没有用。
回答by Shubham Tiwari
Installing "intl" extension on OSX.
在 OSX 上安装“intl”扩展。
- Normally, the PHP is automatically installed on OSX. So, if you would like to use the XAMPP, or whatever apache server, you must change the path point to XAMPP. You can check the path by using:
- 通常,PHP 会自动安装在 OSX 上。因此,如果您想使用 XAMPP 或任何 apache 服务器,您必须更改指向 XAMPP 的路径。您可以使用以下方法检查路径:
$ which php
$哪个php
You should get
你应该得到
/Applications/XAMPP/xamppfiles/bin/php
if not, you will get
如果没有,你会得到
/usr/bin/php.
This is OSX' php. So, you have to change it by using:
这是 OSX 的 php。因此,您必须使用以下方法更改它:
$ PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}"
$ PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}"
- Now, it's time to install intl. Firstly, you need to install icu4c
- 现在,是时候安装 intl 了。首先,您需要安装icu4c
$ brew install icu4c
$ brew 安装icu4c
It takes a couple of times and returns its path to you, should look something like this:
它需要几次并将其路径返回给您,应该如下所示:
/usr/local/Cellar/icu4c/x.x.x
- Next, let's install intl by using pecl
- 接下来,让我们使用 pecl 安装 intl
$ sudo pecl update-channels
$ sudo pecl install intl
$ sudo pecl 更新频道
$ sudo pecl 安装国际
It will prompt you to put the icu4c path. After finish installing icu4c, put the following statement to php.ini
它会提示你输入icu4c路径。安装icu4c后,在php.ini中加入以下语句
extension=intl.so
- Restart apache. and check whether it's neatly installed.
- 重启阿帕奇。并检查是否安装整齐。
$ php -m | grep intl
$ php -m | grep 国际
should return 'intl'
应该返回'国际'
That's it!
就是这样!
回答by HongPong
On OSX if you have homebrew available and have PHP7:
在 OSX 上,如果你有自制软件并且有 PHP7:
$ brew install php70-intl // For PHP7.0
$ brew install php71-intl // For PHP7.1
For PHP5.5:
对于 PHP5.5:
$ brew install php55-intl
Re-open your terminal window to ensure it works right in your session. To see if it loaded via your CLI interpreter:
重新打开您的终端窗口以确保它在您的会话中正常工作。要查看它是否通过 CLI 解释器加载:
$ php -m | grep intl
Or:
或者:
$ php -i "(command-line 'phpinfo()')" | grep intl
Source: https://daveismyname.blog/blog/install-php-intl-on-mac-using-homebrew
来源:https: //daveismyname.blog/blog/install-php-intl-on-mac-using-homebrew
回答by Stan Fad
I failed on my XAMPP on Mac with:
我在 Mac 上的 XAMPP 上失败了:
$ brew install icu4c
, after which I've got message:
,之后我收到了消息:
intl ICU version installed on your system is outdated (4.8.1.1) and does not match the ICU data bundled with Symfony (57.1)
您系统上安装的 intl ICU 版本已过时 (4.8.1.1),并且与 Symfony (57.1) 捆绑的 ICU 数据不匹配
I solved my problem by running command to download, unpack, compile and install ICU of required version (you can choose another version here http://site.icu-project.org/downloadif needed, file should ends with ...src.tgz
):
我通过运行命令下载、解压、编译和安装所需版本的 ICU 解决了我的问题(如果需要,您可以在此处选择另一个版本http://site.icu-project.org/download,文件应以 结尾...src.tgz
):
$ curl -sS -o /tmp/icu.tar.gz -L http://download.icu-project.org/files/icu4c/57.1/icu4c-57_1-src.tgz && tar -zxf /tmp/icu.tar.gz -C /tmp && cd /tmp/icu/source && ./configure --prefix=/usr/local && make && sudo make install
than run:
比运行:
$ sudo pecl install intl
and specified where ICU libraries and headers can be found [DEFAULT] :
并指定在何处可以找到 ICU 库和头文件 [DEFAULT] :
/usr/local
then edited 'php.ini' with extension=intl.so
and reboot apache.
然后用 'php.ini' 编辑extension=intl.so
并重新启动 apache。
Checked result with:
检查结果:
<?php
if (extension_loaded('intl')) {
echo "PHP: " . PHP_VERSION . "<br>\n";
echo "ICU: " . INTL_ICU_VERSION . "<br>\n";
} else {
die('OOPS! The intl extension is not enabled!');
}