简体   繁体   English

如何在 macOS Catalina 上的 PHP 7.3 下安装 intl 扩展?

[英]How do you get the intl extension installed under PHP 7.3 on macOS Catalina?

I have a Mac running Catalina.我有一台运行 Catalina 的 Mac。 This includes PHP 7.3.11 which was installed by default - I haven't modified this in any way.这包括默认安装的 PHP 7.3.11 - 我没有以任何方式修改它。

% php -v
PHP 7.3.11 (cli) (built: Jun  5 2020 23:50:40) ( NTS )

I was trying to run composer install to set up a CakePHP 4 project locally.我试图运行composer install在本地设置 CakePHP 4 项目。 This errors with这与错误

% composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for cakephp/cakephp 4.1.6 -> satisfiable by cakephp/cakephp[4.1.6].
    - cakephp/cakephp 4.1.6 requires ext-intl * -> the requested PHP extension intl is missing from your system.
  Problem 2
    - cakephp/cakephp 4.1.6 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/debug_kit 4.3.7 requires cakephp/cakephp ^4.1 -> satisfiable by cakephp/cakephp[4.1.6].
    - Installation request for cakephp/debug_kit 4.3.7 -> satisfiable by cakephp/debug_kit[4.3.7].

I've created /etc/php.ini and I can see this is being loaded:我已经创建了/etc/php.ini并且可以看到正在加载:

% php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         /etc/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

The php.ini I created was a copy of php.ini.default which came with my Mac.我创建的php.ini是我的 Mac 附带的php.ini.default的副本。 This had the following line commented out这已注释掉以下行

;extension=intl

I've uncommented this and saved as /etc/php.ini .我已取消注释并保存为/etc/php.ini

Now, I'm getting another error when executing php which says:现在,执行php时出现另一个错误,它说:

PHP Warning:  PHP Startup: Unable to load dynamic library 'intl' (tried: /usr/lib/php/extensions/no-debug-non-zts-20180731/intl (dlopen(/usr/lib/php/extensions/no-debug-non-zts-20180731/intl, 0x0009): dlopen(): file not found: /usr/lib/php/extensions/no-debug-non-zts-20180731/intl), /usr/lib/php/extensions/no-debug-non-zts-20180731/intl.so (dlopen(/usr/lib/php/extensions/no-debug-non-zts-20180731/intl.so, 0x0009): dlopen(): file not found: /usr/lib/php/extensions/no-debug-non-zts-20180731/intl.so)) in Unknown on line 0

How do you get intl extension installed under this environment?在这种环境下如何安装intl扩展? I've read that it should be included anyway by default in this version of PHP.我读过它应该默认包含在这个版本的 PHP 中。 Is this some Apple specific problem, or is there a workaround?这是苹果特有的问题,还是有解决方法?

I found a solution ( https://medium.com/@agaetis/solved-install-intl-php-extension-for-xampp-and-magento-for-macos-mojave-41fa42336fc6 ) using brew but this is for PHP 7.1, and doesn't work in this case.我找到了一个使用brew的解决方案( https://medium.com/@agaetis/solved-install-intl-php-extension-for-xampp-and-magento-for-macos-mojave-41fa42336fc6 ),但这适用于 Z2FEC392304A5C23AC138DA228C7 , 在这种情况下不起作用。

You can use a docker image with apache and php (google: docker apache php github), set your project as a volume of your docker container with an external database or use this docker to build a new image with a DB. You can use a docker image with apache and php (google: docker apache php github), set your project as a volume of your docker container with an external database or use this docker to build a new image with a DB.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM