Problem
When trying to install a package through Composer, I got the following messages:
Openssl error
The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl extension, you can disable this error , at your own risk, by setting the 'disable-tls' option to true.
Curl error
After solving the openssl issue, I got another message:
Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.
Solution
Here’s what I did to solve it:
- Type
which php
in the terminal to find out which PHP is being used on the local machine. - According to the path you got, open the file explorer and navigate to the folder where php.exe is located. I use “Local WP” to run the local PHP environment so this folder was something like:
C:\Users\your.user\AppData\Roaming\Local\lightning-services\php-7.4.30+5\bin\win64
- In this folder, look for the
php.ini
file. If there are onlyphp.ini-development
andphp.ini-production
files - rename one of these files tophp.ini
. - Edit the
php.ini
file. - Uncomment
;extension_dir = "ext"
by removing the;
at the beginning. - Uncomment
;extension=curl
- to solve the curl issue. - Uncomment
;extension=openssl
- to solve the openssl issue. - Save the file.
- Restart the terminal and try again.