1

When I attempt to run composer install in the CLI, I get this error:

You must enable the openssl extension to download files via https

The problem seems to be on line 5381 of my composer.phar file:

if (!extension_loaded('openssl') && (0 === strpos($url, 'https:') || 0 === strpos($url, 'http://github.com'))) {
    throw new \RuntimeException('You must enable the openssl extension to download files via https');
}

I have enabled the openssl extension in both my php.ini files. (Apache and PHP)

If I run openssl version in the CLI it returns

OpenSSL 1.0.1c 10 May 2012

I ran the following PHP script through my WAMP server:

echo extension_loaded('openssl');

It printed 1

As far as I can tell, my openssl extension is working fine, but for some reason it is still causing this error for Composer.

Does anyone see any problems I may have overlooked?

twiz
  • 9,041
  • 8
  • 52
  • 84
  • possible duplicate of [Composer Warning: openssl extension is missing. How to enable in WAMP](http://stackoverflow.com/questions/14062055/composer-warning-openssl-extension-is-missing-how-to-enable-in-wamp) – Mohit Nov 10 '13 at 11:41
  • Possible duplicate of [You must enable the openssl extension to download files via https](http://stackoverflow.com/questions/14291151/you-must-enable-the-openssl-extension-to-download-files-via-https) – jww Jun 19 '15 at 02:06

3 Answers3

4

There is a difference between PHP running inside a HTTP server, and on command line - both cases use their own configuration, so it might be that your command line version has not SSL extension configured.

Check for yourself: php -i shows you the phpinfo output on the command line. Any OpenSSL to be seen?

While you are at it, use the same output, locate the info on which php.ini is being used, and add the OpenSSL extension.

Sven
  • 69,403
  • 10
  • 107
  • 109
  • 1
    I did what you said. Openssl was disabled in one of `php.ini` files I mentioned I had enabled it in. I seriously checked it like 5 times earlier... As always, I probably just did something stupid. Anyway, even though the correct answer should have been `Don't be an idiot`, I'm going to accept yours. ;-) – twiz Aug 03 '13 at 00:35
2

As you did not provide a lot of information, I just assume that your system setup (Windows XP, WAMP) is similar to mine. In principle this answer should work on Unix but I am not able to check it.

Anyway, I had PHP running on WAMP and I had set up the ini-files correctly but still I got the same error as you did. After doing some research and a lot of tinkering, I noticed that the PHP running on command line did not actually use any ini-files (command php --ini). After noticing that, I got composer running properly by setting the ini-file with php -c command.

Long story short, try this command php -c /path/to/ini/file composer install and see if it works.

TheQ
  • 21
  • 1
0

Here is how I solved the problem while installing Composer. I had saved the php file to c:\php. In the php.ini file I opened the extension =php_openssl.dll by removing the semi colon with no success. i found the extension openssl.dll in the sub directory called ext . I copied it to the c:\php directory. I met with immediate success. What a hassle! Glad to move on.

Dion
  • 1