0

After PHP being updated on our server (Centos 5.11) to be > v5.3.2, I want to get Composer installed like I have in my other environments.

The Composer docs state that "Composer requires PHP 5.3.2+ to run". I have PHP 5.4.45. Still, when trying

curl -sS https://getcomposer.org/installer | php

It exits with the warning

PHP Warning:  file_get_contents(https://getcomposer.org/versions): failed to open stream: Connection timed out in - on line 762
PHP Warning:  Invalid argument supplied for foreach() in - on line 508
None of the 0 stable version(s) of Composer matches your PHP version (5.4.45 / ID: 50445)

I found this answer which deals with ignoring system requirements when installing Composer.

Is this something that could be done or is it a somewhat scary/thoughtless thing to do? And, are there other versions ("unstable" or otherwise) of Composer that I could use? Or perhaps PHP should be updated again -> 5.6.x?

Thanks for any tips and help!

Community
  • 1
  • 1
Kyrre
  • 670
  • 1
  • 5
  • 19
  • This doesn't answer your question, but yes, you should upgrade PHP further. [PHP 5.4 stopped receiving security updates in September, 2015 and PHP 5.5 stopped receiving them in July, 2016. PHP 5.6 and 7.0 will receive security updates until roughly the end of 2018.](https://secure.php.net/supported-versions.php) – ChrisGPT was on strike Aug 17 '16 at 13:12
  • looks like it is ipv6 issue. after disable ipv6 the installer was was forced to use ipv4 for the address resolution and all went fine. – legacyofleo May 20 '17 at 08:15

3 Answers3

3

I changed from https to http,

curl -sS http://getcomposer.org/installer | php

Then was able to install

2

It's not a matter of your PHP version, but a connectivity issue.

You have 3 messages (2 warnings and one composer's info), which tell you the whole story.

(1st warning) Composer's installer couldn't fetch list of Composer's list of versions due to connection timeout, so (2nd warning) it didn't have a list to iterate over and match Composer's version suitable for your PHP version, which implied that (3rd message) no version of composer was found.

The root problem is the first warning. This line

file_get_contents(https://getcomposer.org/versions);

didn't work. And that's your issue.

It's hard to tell you exact solution basing of provided information.

Jakub Matczak
  • 15,341
  • 5
  • 46
  • 64
  • Indeed it is. Thank you for pointing it out. This seems harder to do anything about though, as "curling" something like example.com does return the expected result, albeit very slowly. A problem with composer.org perhaps? Or curl timing out prematurely? – Kyrre Aug 17 '16 at 07:41
  • It may be somthing with SSL. Did you try to execute only that `file_get_contents(https://getcomposer.org/versions);` in a test file? – Jakub Matczak Aug 17 '16 at 07:46
  • Yes, it does return the same data as you can see [here](https://getcomposer.org/versions). Although the first few times I tested it, it did not work, claiming "No such file or directory". But it is now consistent. Something seems fishy. Could it be a syntax error? There are no quotes surrounding the url parameter.. But that could be a result of the terminal output. I must dig deeper – Kyrre Aug 17 '16 at 07:57
  • 1
    line 507 `$versions = json_decode($httpClient->get($uriScheme . '://getcomposer.org/versions'), true);` from [the installer on GitHub](https://github.com/composer/getcomposer.org/blob/master/web/installer) is the culprit, but there can't really be anything wrong there. Has to be something on my system. – Kyrre Aug 17 '16 at 08:02
0

I think it could be proxy problems. Deleting the https_proxy and http_proxy environment vars worked for me (Windows 10). And then installing it, set proxy in blank. It should work as it did for me.

DavidQuezada7
  • 149
  • 2
  • 7