26

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
Veysel BAYAR
  • 261
  • 1
  • 3
  • 4
  • Are you sure you changed the right `php.ini` file. Do a `php --ini` to see which `php.ini` file your PHP CLI is using – RiggsFolly Oct 01 '18 at 15:39
  • 1
    The PHP CLI and the PHP used by Apache are not necessarily related to each other. Restarting Apache is Irrelevant to PHP CLI and again makes me think you are editing the wrong `php.ini` file – RiggsFolly Oct 01 '18 at 15:41
  • @RiggsFolly I see but I'm sure about I edited correct php.ini file. Because I checked before editing using `phpinfo()` method – Veysel BAYAR Oct 01 '18 at 15:46
  • `phpinfo()` will tell you which `php.ini` file is being used by the PHP that is running with APache. **This is NOT NECESSARILY the same `php.ini` that is being used by the PHP CLI** _Command Line Interface_ – RiggsFolly Oct 01 '18 at 15:48
  • 1
    from the terminal do `> php --ini` and ___look at the output___. It will tell you **which `php.ini` file is being used by the PHP CLI** – RiggsFolly Oct 01 '18 at 15:49
  • Look for `Loaded Configuration File` – RiggsFolly Oct 01 '18 at 15:51
  • @RiggsFolly yeah you are righti loaded configuration file shows php7/php.ini but cli shows php5/.php.ini ... how can ı fix this ? – Veysel BAYAR Oct 01 '18 at 15:59
  • Thats a totally different question. What Operating System are you using – RiggsFolly Oct 01 '18 at 16:09
  • @RiggsFolly Windows 8.1 – Veysel BAYAR Oct 02 '18 at 09:42
  • 1
    I would have to guess that you have 2 PHP's installed. I would also guess that you PATH is pointing to the PHP5 folder and thats why you get that in the CLI. Check your PATH and if I am right change the PATH to point to the PHP7 folder – RiggsFolly Oct 02 '18 at 09:47
  • Hey! I also have Windows 8.1 and I had the same issue. The problem was that I used PHP v.7.0, I changed it to 7.3 and it was the solution. – borkafight Mar 02 '20 at 19:41

2 Answers2

74

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
Tharaka Devinda
  • 1,952
  • 21
  • 23
4

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!

hackernewbie
  • 1,606
  • 20
  • 13