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:

  1. Type which php in the terminal to find out which PHP is being used on the local machine.
  2. 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
  3. In this folder, look for the php.ini file. If there are only php.ini-development and php.ini-production files - rename one of these files to php.ini.
  4. Edit the php.ini file.
  5. Uncomment ;extension_dir = "ext" by removing the ; at the beginning.
  6. Uncomment ;extension=curl - to solve the curl issue.
  7. Uncomment ;extension=openssl - to solve the openssl issue.
  8. Save the file.
  9. Restart the terminal and try again.