Composer not working on windows, gives [Composer\Exception\NoSslException] error

32,676

Solution 1

I had the same issue. I did the following things to make sure the composer works out.

  • Find the php.ini which corresponds to where you issue the command from.

php --ini

sample output before correction:

Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File:         (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

This C:\WINDOWS here is a hoax. When I looked in the php installation directory, I found out there is NO php.ini. There are two files php.ini-development and php.ini-production. Just rename one to php.ini

Then you should see the correct ini path when you do php --ini

  • Set the extensions directory

Afterwards, open the php.ini file and uncomment the following line ;extension_dir = "ext" should be

extension_dir = "ext"
  • Enable extensions

Then uncomment the extensions the same way. The following are usually required. (But please find out what you need from the messages you see from composer commands)

extension=fileinfo
extension=gd2
extension=mbstring
extension=openssl

Solution 2

I was running php7.2.x on my Windows 10 machine before I upgraded to PHP 7.4.10 (cli)

When I first pulled up the php.ini file, to my surprise, it was empty.

To be sure that I was looking at the right file, I did

php --ini

I was looking at the correct file.

I looked at the php folder of XAMPP and noticed two files:

  1. php.ini-production.ini
  2. php.ini-development.ini

I copied the contents of the first file and pasted in my php.ini file. Then after a restart, I saw a ton of other modules were not being loaded.

I then went in to my php.ini file's Dynamic Extensions sections and had to uncomment all the following extensions:

extension=bz2
extension=curl
extension=ffi
extension=ftp
extension=fileinfo
extension=gd2
extension=gettext
extension=gmp
extension=intl
extension=imap
extension=ldap
extension=mbstring
extension=exif      ; Must be after mbstring as it depends on it
extension=mysqli
extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
extension=odbc
extension=openssl
extension=pdo_firebird
extension=pdo_mysql
extension=pdo_oci
extension=pdo_odbc
extension=pdo_pgsql
extension=pdo_sqlite
extension=pgsql
extension=shmop

And then restarted Apache server agan, after saving my php.ini file.

This time, everything worked!

Share:
32,676
Veysel BAYAR
Author by

Veysel BAYAR

Updated on September 03, 2020

Comments

  • Veysel BAYAR
    Veysel BAYAR over 3 years

    I'm trying to install laravel on windows 10. I installed composer to install laravel but it gives me below error.

    [Composer\Exception\NoSslException] The openssl extension is required for SSL/TLS protection but is not availab le. 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.

    Command doesn't matteri it gives above error with all commands...

    I checked out this question and used solutions but it didin't work for me..

    I tried these solutions

    composer config -g -- disable-tls true
    
    extension=php_openssl.dll // open openssl extension in php.ini file. - I restarted apache after that but nothing changed
    
  • Colin Gell
    Colin Gell about 4 years
    Thank you this fixed my issue
  • Onimusha
    Onimusha almost 4 years
    Just copying the php.ini to C:\Windows sufficed for me
  • Artur Müller Romanov
    Artur Müller Romanov almost 3 years
    If this doesn't help, try this: youtrack.jetbrains.com/issue/WI-52973
  • Jovylle
    Jovylle over 2 years
    Waw your my angel.
  • Ekene Mefor
    Ekene Mefor almost 2 years
    This should have been the correct and voted answer!!!!!!!!!!!!! it works like charm
  • Jagarkin
    Jagarkin almost 2 years
    everything is correct but for some reason i don't see the Path: C:\WINDOWS it is just empty when i type php --ini