Php – Problems with lib-icu dependency when installing Symfony 2.3.x via Composer

composer-phpPHPsymfony

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

(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

But got shutdown by the following errors:

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

Do I need to tweak the composer.json file?


Solution Update

I was missing the php intl extension which provides lib-icu

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:

My steps:

  • 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

Command Line:

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

Best Answer

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

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

( 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

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

Check your current intl versions from php with:

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

attention: not needed anymore ( symfony 2.3 has meanwhile been released )

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 

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

Related Topic