在 Mac 上的 XAMPP 上安装 PHP 国际化扩展 (Intl)

2024-04-12php开发问题
62

本文介绍了在 Mac 上的 XAMPP 上安装 PHP 国际化扩展 (Intl)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

如何在 OS X 上的 XAMPP 服务器上安装 Intl?

我尝试修改我的 XAMPP>etc>php.ini 并取消注释该行:

;extension=php_intl.dll

并重新启动 Apache,但没有成功.

解决方案

在 OSX 上安装intl"扩展.

  1. 通常,PHP 会自动安装在 OSX 上.因此,如果您想使用 XAMPP 或任何 apache 服务器,您必须将路径点更改为 XAMPP.您可以使用以下命令检查路径:

<块引用>

$哪个php

你应该得到

/Applications/XAMPP/xamppfiles/bin/php

如果没有,你会得到

<代码>/usr/bin/php.

这是 OSX 的 php.ini 文件.因此,您必须使用以下方法更改它:

<块引用>

$PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}"

  1. 现在是安装 intl 的时候了.首先,你需要安装icu4c

<块引用>

$ brew install icu4c

它需要几次并返回它的路径给你,应该是这样的:

/usr/local/Cellar/icu4c/x.x.x

  1. 接下来,让我们使用 pecl 安装 intl

<块引用>

$ sudo pecl 更新频道

$ sudo pecl install intl

它会提示你输入 icu4c 路径.完成安装icu4c后,将以下语句放入php.ini

extension=intl.so

  1. 重启apache.并检查是否安装整齐.

<块引用>

$ php -m |grep intl

应该返回'intl'

就是这样!

How can I install Intl on my XAMPP server on OS X?

I tried modifying my XAMPP>etc>php.ini and uncommenting the line:

;extension=php_intl.dll

and restarting Apache, but it didn't work.

解决方案

Installing "intl" extension on OSX.

  1. 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:

$ which 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:

$ PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}"

  1. Now, it's time to install intl. Firstly, you need to install icu4c

$ brew install 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 

  1. Next, let's install intl by using pecl

$ sudo pecl update-channels

$ sudo pecl install intl

It will prompt you to put the icu4c path. After finish installing icu4c, put the following statement to php.ini

extension=intl.so

  1. Restart apache. and check whether it's neatly installed.

$ php -m | grep intl

should return 'intl'

That's it!

这篇关于在 Mac 上的 XAMPP 上安装 PHP 国际化扩展 (Intl)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17