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

PhpSymfonyComposer Php

Php Problem Overview


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.

Php Solutions


Solution 1 - Php

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.

Solution 2 - Php

Many applications will only be supporting "en" locale and will have no need for translation capabilities or php-intl. If this is you, or you can't install php-intl on your server, you can explicitly add symfony/icu ~1.0 to your composer.json. 1.0 does not require php-intl, whereas 1.1+ does.

If you don't need translation features:

$ php bin/composer.phar require symfony/icu ~1.0

Without this declaration and trying to install symfony/symfony 2.3 Composer may try to install symfony/icu ~1.2 which would require you to install php-intl.

This is explicitly covered more extensively in the Symfony Intl Component's docs under "ICU and Deployment Problems".

Solution 3 - Php

A solution regarding this or similar problems can be found here: ICU and Deployment Problems

The behavior of composer should be intelligent selecting the right icu-component: >- symfony/icu 1.0.: when the intl extension is not available >- symfony/icu 1.1.: when intl is compiled with ICU 4.0 or higher >- symfony/icu 1.2.*: when intl is compiled with ICU 4.4 or higher

There should be (theoretically) no error installing symfony 2.3. with no intl-extension.

But you can be trapped when your development-environment differs from your production-server like mentioned in this article:

>- the development machines are compiled with ICU 4.4 or higher, but the server is compiled >with a lower ICU version than 4.4 >- the intl extension is available on the development machines but not on the server.

When you have no root-access to your production-server you can fix it as mentioned in this article. (tweaking composer.json)

Hope this additional information helped as it helped me for this special case with different environments.

Solution 4 - Php

Mac OS Mavericks comes with PHP 5.4.17 without intl. To get this, you'll have to follow those steps :

brew install icu4c
sudo pecl install intl 
The path to the ICU libraries and headers is: /usr/local/opt/icu4c/
Edit /etc/php.ini and add extension=intl.so to the end.

Solution 5 - Php

I know that this answer may not be the correct answer to this person's problem, but it was the solution to my problem with the same title. I was able to fix this problem for myself by enabling the intl extension in php.ini and upgrading composer.

Upgrading composer.

php composer.phar self-update

Remove comment from this line (in php.ini):

extension=php_intl.dll

And also remove comment the these two lines below [intl] in (php.ini):

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

And restart apache2 of course. :)

Additional Information:

If your using mac and installed php with Homebrew follow these steps:

(PHP 5.4)

$ brew install php54-intl

(PHP 5.5)

$ brew tap josegonzalez/php
$ brew tap homebrew/dupes
$ brew install josegonzalez/php/php55-intl
$ sudo apachectl restart

Restart apache.

Solution 6 - Php

A better solution is to fix your composer.json to the version required by the production server. First, determine the ICU version on the server: 1 2

$ php -i | grep ICU
ICU version => 4.2.1

Then fix the Icu component in your composer.json file to a matching version:

"require: {
    "symfony/icu": "1.1.*"
}

Set the version to "1.0." if the server does not have the intl extension installed; "1.1." if the server is compiled with ICU 4.2 or lower.

Finally, run

php composer.phar update symfony/icu

on your development machine, test extensively and deploy again. The installation of the dependencies will now succeed.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMark FoxView Question on Stackoverflow
Solution 1 - PhpNicolai FröhlichView Answer on Stackoverflow
Solution 2 - PhpJohn KaryView Answer on Stackoverflow
Solution 3 - PhptweiniView Answer on Stackoverflow
Solution 4 - PhplenybernardView Answer on Stackoverflow
Solution 5 - PhpLayton EversonView Answer on Stackoverflow
Solution 6 - PhpthewbbView Answer on Stackoverflow