Composer says the openssl extension is missing on Windows
Composer Warning: openssl extension is missingShort answer
Composer needs PHP's OpenSSL extension for HTTPS. On Windows it is a line in php.ini that ships commented out. Remove the semicolon in the php.ini that the command line PHP loads, which is often not the one your web server uses, then open a new terminal. Do not set disable-tls.
Fix it fast
1Find out which cause you have
Ask the PHP that Composer uses which config file it loaded and whether OpenSSL is present.
php --ini php -m | findstr /i openssl2Match what you see, then jump to its fix
What does the error look like?
Composer Warning: openssl extension is missingphp -m does not list openssl
Cause 1 of 2
The extension line is still commented out
1Check
PHP ships its php.ini templates with the line for openssl commented out under Dynamic Extensions. A leading semicolon means it is off.
findstr /n /i "extension=openssl" "C:\path\to\php.ini"2Fix
Open the php.ini shown by php --ini and remove the semicolon so the line reads extension=openssl. Check that extension_dir points at the ext folder of that PHP.
extension=openssl3Verify
Open a new terminal (the old one keeps the old settings) and list modules again.
php -m | findstr /i openssl
composer diagnoseConfirmed by raw.githubusercontent.com
Cause 2 of 2
You edited a php.ini the command line does not load
1Check
PHP searches several places for its config, and it looks for php-SAPI.ini (for example php-cli.ini) before php.ini. The web server and the command line can load different files.
php --ini
where php2Fix
Edit the file that php --ini reports for the CLI, or point the CLI at the file you want with the -c option. Make sure the PATH entry runs the PHP you meant.
php -c "C:\path\to\php.ini" -m | findstr /i openssl3Verify
Run Composer again from a new terminal.
composer diagnoseConfirmed by php.net
How do I stop it coming back?
- Run php --ini after each PHP upgrade, because the new install may bring a fresh php.ini.
- Never set Composer's disable-tls: its docs call it a security risk and tell you to enable the extension instead.
- Keep one PHP on PATH for the command line and know which one your web server uses.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
Apache returns 403 when a URL contains %3F
a request like /page%3Fname=test is refused while /page?name=test works
Recent Apache httpd blocks a rewrite when the request contains an encoded question mark (%3F) and the rewritten target has a literal ?.
2 causes, each with a fixBack end
Apache returns 500 with Premature end of script headers
500 Internal Server Error
Apache ran your script, but the script printed no valid HTTP header before its output.
3 causes, each with a fixBack end
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fixBack end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fixBack end
AWS SDK for PHP rejects requests: the signature is from the future
Signature not yet current: {date} is still later than {date}
AWS compares the timestamp in your signed request with its own clock.
2 causes, each with a fix