8

I am trying to install Composer for Windows using the command line with the following call:

php -r "readfile(https://getcomposer.org/installer);" | php

However, I get this error message:

Warning: readfile(): Unable to find the wrapper "https" - did you forget to enable it when configured PHP? in Command line code on line 1

Call Stack: 0.0010 224336 1. {main}() Command line code:0 0.0010 224488 2. readfile() command line code:1

Warning: readfile(https://getcomposer.org/installer): failed to open stream: invalid argument in Command line code on line 1

Call Stack: 0.0010 224336 1. {main}() Command line code:0 0.0010 224488 2. readfile() Command line code:1

I have already uncommented the ";extension=php_openssl.dll" line in the php5.5.12 directory, restarted the browser, and tried other variants. When I run the command with just the 's' in https dropped, I get:

Some settings on your machine make Composer unable to work properly. Make sure that you fix the issues listed below and run this script again:

The openssl extension is missing, which means that secure HTTPS transfers are impossible. If possible you should enable it or recompile php with --with-openssl

I've tried including this --with-openssl flag at various places but it doesn't seem to be doing the trick.

Adam Freymiller
  • 1,929
  • 7
  • 27
  • 49
  • 1
    possible duplicate of [Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?](http://stackoverflow.com/questions/5444249/unable-to-find-the-wrapper-https-did-you-forget-to-enable-it-when-you-config) – Havenard Mar 23 '15 at 01:06
  • 2
    all of the answers in that post are addressing something which I've already done, which is uncomment the line in the php.ini file on "extension=php_openssl.dll" – Adam Freymiller Mar 23 '15 at 01:41
  • Have you restarted the server after doing that? – Havenard Mar 23 '15 at 01:54
  • yes, I already tried that – Adam Freymiller Mar 23 '15 at 02:09
  • I know this is really old. Just want to tell future readers what my fix was. The line "extension=php_openssl.dll" wasn't in my php.ini file. I had it – JonR85 Aug 08 '21 at 17:11

4 Answers4

11

This sounds like your installation hasn't got openssl enabled.

Locate your php.ini file (on Windows this is probably in the same place as the php.exe (c:\php on my machine).

Open it in your favourite editor, and locate the line

;extension=php_openssl.dll

remove the semi-colon

extension=php_openssl.dll

HTTPS should now work for you from within php.

Graeme
  • 1,643
  • 15
  • 27
6

It works by using Havenard's answer. Just add '..' to enclose the url

php -r "readfile('http://getcomposer.org/installer');" | php -- --disable-tls
5

Well, since the solution doesn't seem to work for you for whatever reason, you can observe that all this command is doing is download the file and printing it into another php process. This is a rather simple problem that can be workarounded with minor adaptations.

You can for instance, drop https and use http:

php -r "readfile('http://getcomposer.org/installer');" | php -- --disable-tls

Or let some other tool fetch this file, such as:

wget -s -O - "https://getcomposer.org/installer" | php -- --disable-tls

Or even:

curl -sSk "https://getcomposer.org/installer" | php -- --disable-tls

The option --disable-tls is relevant to the installer script, it will tell it to use http instead of https in the furter downloads it will perform during the installation.

Havenard
  • 27,022
  • 5
  • 36
  • 62
0

In my case (Windows 10, PHP 7.3.24) it was

extension=openssl

(https://stackoverflow.com/a/63460807/7508553)

Sergey Beloglazov
  • 342
  • 1
  • 3
  • 14