Whenever I try to do something with Composer I always get this error:

“In Factory.php line 654: 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.”

Even after I enabled the openssl extension in the php.ini-development and php.ini-production by uncommenting it, I used to get these errors. But I found the fix!

Sometimes, when downloading the PHP files from windows.php.net, we get some corrupt downloads. It only happens sometimes. What I got missing is the “php.ini” file.

The php.ini file is used to declare changes to your PHP settings like enabling or disabling extensions. Due to some reasons When I downloaded the PHP folder, it stopped before finishing the full download.

The fix:

As our PHP folder is corrupt we should download PHP again. Here’s the link: https://windows.php.net/download. Always download the Thread Safe version of PHP. After we downloaded PHP in a zip format we needed to unzip it in our “C:” drive.

We should reinstall Composer because Composer was installed on the corrupt PHP folder, now we need it to be installed on the newly downloaded PHP folder. We need to delete the composer.phar(C:\Users\<username>\AppData\Roaming\Composer) and after that, we need to delete the composer folder. If you don’t see the AppData folder, In your file explorer in the view tab enable “View hidden files” and AppData will be visible. Now we can reinstall Composer

For Windows, we should install the exe version. when the composer installer shows this, choose the new PHP that you downloaded before

After that You should enable “Add this PHP to your path? It will replace the existing entry.” and its done

Composer is fixed and will not show any errors!


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *