twiz
twiz

Reputation: 10558

OpenSSL error with Composer PHP package manager

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?

Upvotes: 1

Views: 7410

Answers (3)

Dion
Dion

Reputation: 1

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.

Upvotes: 0

TheQ
TheQ

Reputation: 21

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.

Upvotes: 2

Sven
Sven

Reputation: 70853

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.

Upvotes: 4

Related Questions