114

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.
Mark Fox
  • 8,694
  • 9
  • 53
  • 75

6 Answers6

119

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.

Nicolai Fröhlich
  • 51,330
  • 11
  • 126
  • 130
  • Great article. The Composer documentation left me less than certain what if anything the stability flag was coming into play. – Mark Fox May 25 '13 at 19:54
  • I installed php-intl via PEAR/PECL. For some reason `INTL::…` fails. But, I can see via phpinfo() in the browser that Intl is installed and the ICU version is 49.x. However, Composer still fails with the same error message. – Mark Fox May 25 '13 at 21:52
  • which operating system ? "sudo aptitude install php5-intl" on ubuntu for example. extension enabled in php.ini , visible with php -m from commandline ? – Nicolai Fröhlich May 25 '13 at 21:57
  • 1
    Mac OSX 10.7.5 — when I run `php -m` I do NOT see intl. I know it works on the webserver, but it's not recognized on the Command Line. So… I have to add it to the Command Line? – Mark Fox May 25 '13 at 22:07
  • I installed via Homebrew, but `php -m` still does not recognize from CLI? – Mark Fox May 25 '13 at 22:29
  • do you maybe have a different php.ini for php-cli where the extension is not enabled ? – Nicolai Fröhlich May 25 '13 at 22:30
  • as you said it's included in phpinfo, are you sure? try phpinfo(INFO_MODULES); – Nicolai Fröhlich May 25 '13 at 22:33
  • Got it working after updating my php cli's php.ini. Thanks for the help. However, when I run Intl::getIcuVersion() on the web server I always get an error, at least with the PECL installed intl extension. – Mark Fox May 26 '13 at 02:02
  • It is stupid for Symfony2 to require this package, since the vast majority of web sites do not need internationalization. See John Kary's answer below for the steps to circumvent this entire process. – Acyra Aug 08 '13 at 13:41
  • FYI: `Intl` is a symfony class, if you're not using symfony use the PHP constant `INTL_ICU_VERSION`, or a more comprehensive lookup is in the source for `Intl::getIcuVersion()` this [github branch merge](https://github.com/symfony/symfony/commit/df88070e76423e5bd63285ba75ccae6094a89e5b) – zamnuts Jan 29 '14 at 06:27
  • Thanks for the addition @zamnuts, i should probably add that information to the answer :) – Nicolai Fröhlich Jan 29 '14 at 14:42
  • @nifr, I am in same problem. I could not solve my problem with your solution. Thanks – julious ceazer May 10 '15 at 10:02
  • when i run sudo brew install icu6c.i have this error:::W: be careful as root. Don't run this as root! – pedram shabani Mar 26 '18 at 14:37
21

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

John Kary
  • 6,703
  • 1
  • 24
  • 24
  • 1
    Thanks for this. It is absurd that Symfony2 shuts down installation over a feature that should be optional and isn't installed in many environments. – Acyra Aug 08 '13 at 13:38
  • Sorry, but that is not true. Installing symfony 2.3 will introspect the configuration and will determine the correct icu-component. It will NOT shut down. – tweini Aug 27 '13 at 01:51
  • **POC** composer.json :`"require":{"symfony/symfony": "v2.3.3"}}` result: ´Loading composer repositories with package information Installing dependencies (including require-dev) - Installing psr/log (1.0.0) Downloading: 100% - Installing twig/twig (v1.13.2) Downloading: 100% - Installing doctrine/common (2.3.0) Downloading: 100% - Installing symfony/symfony (v2.3.3) Downloading: 100% - Installing symfony/icu (v1.0.0) Downloading: 100% Writing lock file Generating autoload files – tweini Aug 27 '13 at 02:06
  • 1
    As explained in the docs, the problem arises when `composer.lock` is shared between environments with different versions (or absence) of Intl. – Tamlyn Nov 27 '13 at 17:59
  • Thanks for this! Crossing my fingers I can get my Symfony2 project running for a client who is on GoDaddy still – Matt Jan 11 '14 at 07:55
15

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.

tweini
  • 806
  • 8
  • 12
9

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.
lenybernard
  • 2,399
  • 22
  • 22
6

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.

Layton Everson
  • 1,148
  • 9
  • 18
  • 1
    Looks like this is the Windows fix ;-) – Mark Fox May 27 '13 at 19:25
  • 1
    Yes, I'm using windows, however, its not a "windows fix" its a php config and composer update fix. Same steps may need to be taken on a linux or mac box. – Layton Everson May 28 '13 at 21:13
  • Correct. Perhaps you should mention which php/apache distribution you're using then. In your case the intl extension is bundled and just needs to be enabled, that's great news for anyone using the same distro package. – Mark Fox May 28 '13 at 22:41
  • 1
    Good point Mark Fox. Here we are for anybody needing it. I'm using the XAMPP stack from apachefriends on a windows 8 box. (version 1.8) – Layton Everson May 29 '13 at 04:22
  • 1
    For me this fixed it using XAMPP. The extension was already enabled, but it worked only after adding [intl] intl.default_locale = en_utf8 intl.error_level = E_WARNING – d0001 Jun 12 '13 at 02:44
5

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.

thewbb
  • 236
  • 4
  • 8