本文介绍了通过 Composer 安装 Symfony 2.3.x 时出现 lib-icu 依赖问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Composer 安装 Symfony 2.2.x 没有任何问题,我一直只是在 http://symfony.com 复制稳定版本/下载.

I've had no problems installing Symfony 2.2.x using Composer, I've always just copied the stable version at http://symfony.com/download.

composer create-project symfony/framework-standard-edition myproject/ 2.2.1

(我已全局安装 Composer)
对 2.3.0-RC1 感到好奇,我认为这会顺利进行:

(I have Composer installed globally)
Curious about 2.3.0-RC1 I figured this would go smoothly:

composer create-project symfony/framework-standard-edition mynewerproject/ 2.3.0-RC1

但因以下错误而关闭:

Your requirements could not be resolved to an installable set of packages.

Problem 1
    - symfony/icu v1.2.0-RC1 requires lib-icu >=4.4 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    - symfony/icu v1.1.0-RC1 requires lib-icu >=3.8 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    - symfony/symfony v2.3.0-RC1 requires symfony/icu >=1.0,<2.0 -> satisfiable by symfony/icu[v1.1.0-RC1, v1.2.0-RC1].
    - Installation request for symfony/symfony 2.3.* -> satisfiable by symfony/symfony[v2.3.0-RC1].

我需要调整 composer.json 文件吗?

Do I need to tweak the composer.json file?

如此简单,安装和配置 intl 扩展.自 PHP 5.3 起,默认分发 Intl 扩展,但某些分发,如 MAMP,没有 Intl,因此您需要获取它.我用:

So easy, install and configure the intl extension. As of PHP 5.3 the Intl extension is distributed by default, but some distributions, like MAMP, don't have Intl so you'll need to acquire it. I used PEAR:

我的步骤:

  • 安装 Intl 扩展(由 PECL 维护):$ pear install pecl/intl — 您可能需要先将 pecl 通道添加到 pear.
  • 如果您使用 MAMP 并且从未使用过 pear/pecl,请检查 lullabot 的有用博文;MAMP 不附带 php 源代码,因此您必须下载您的 php 版本的源代码并将源代码移动到/Applications/MAMP/bin/php/php[version]/include/php(如博文中所述)
  • PEAR 找不到我的 php.ini,所以我不得不手动将 extension=intl.so 添加到 php.ini.在 MAMP 中,您可以通过转到文件 > 编辑模板 > php.[version].ini
  • 轻松编辑 php.ini
  • Install the Intl extension (maintained by PECL): $ pear install pecl/intl — you may have to add the pecl channel to pear first.
  • If you use MAMP and have never worked with pear/pecl check lullabot's helpful blog post; MAMP doesn't ship with the php source, so you have to download the source for your php version and move the source into /Applications/MAMP/bin/php/php[version]/include/php (as covered in the blog post)
  • PEAR couldn't find my php.ini, so I had to manually add extension=intl.so to php.ini. In MAMP you can edit php.ini easily by going to File > Edit Template > php.[version].ini

命令行:

  • 使用 Composer 或 Symfony 的控制台 CLI 时,您还需要 Intl,并且由于 php CLI 通常使用不同的 php.ini,因此您需要添加扩展那里也有指令.要查找 CLI 的 php.ini,只需执行 $ php -i |grep php.ini 以发现文件路径并将 extension=intl.so 添加到该 php.ini也一样.
  • 要检查是否安装了 Intl,您可以执行 $ php -m 来检查可用模块.
  • When using Composer or Symfony's Console CLI you'll also need Intl and since the php CLI usually uses a different php.ini you'll want to add the extension directive there too. To find your CLI's php.ini simply do $ php -i |grep php.ini to discover the file path and add extension=intl.so to that php.ini as well.
  • To check if Intl is installed you can do $ php -m to check available modules.

推荐答案

更新你的 php-intl 扩展,这就是 icu 错误的来源!

update your php-intl extension, that's where the icu error comes from!

sudo aptitude install php5-intl                 // i.e. ubuntu
brew install icu4c                              // osx

检查扩展是否已启用并在 php.ini 中正确配置.

check the extension is enabled and properly configured in php.ini aswell.

(提示:php-cli 有时使用不同的 php.ini)

( hint: php-cli sometimes uses a different php.ini )

php.ini

extension=intl.so       ; *nix
extension=php_intl.dll  ; windows

[intl]
intl.default_locale = en_utf8
intl.error_level = E_WARNING

如果扩展已成功启用,请从终端检查您的 phpinfo()php -m.

check your phpinfo() AND php -m from your terminal if the extension has been succesfully enabled.

使用以下命令从 php 检查您当前的 intl 版本:

Check your current intl versions from php with:

Intl::getIcuVersion();
Intl::getIcuDataVersion();

注意:不再需要(symfony 2.3 已同时发布)

请像这样将最低稳定性标志@dev 或@rc 添加到您的依赖项中:

add the minimum stability flag @dev or @rc to your dependency like this please:

composer create-project symfony/framework-standard-edition mynewerproject/ 2.3.*@dev

composer 中的默认稳定性是 symfony 2.3 分支当前不是稳定的(它是 @rc ).阅读更多稳定性标志这里.

The default stability in composer is stable which symfony 2.3 branch is not currently ( it's @rc ). Read more an stability flags here.

这篇关于通过 Composer 安装 Symfony 2.3.x 时出现 lib-icu 依赖问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 17:08
查看更多