简体   繁体   English

Composer 在 Windows 上不工作,给出 [Composer\\Exception\\NoSslException] 错误

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

I'm trying to install laravel on windows 10. I installed composer to install laravel but it gives me below error.我正在尝试在 Windows 10 上安装 laravel。我安装了 composer 来安装 laravel,但它给了我以下错误。

[Composer\\Exception\\NoSslException] The openssl extension is required for SSL/TLS protection but is not availab le. [Composer\\Exception\\NoSslException] openssl 扩展是 SSL/TLS 保护所必需的,但不可用。 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.如果您无法启用 openssl 扩展,您可以通过将 'disable-tls' 选项设置为 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

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。

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.这里的 C:\\WINDOWS 是一个骗局。 When I looked in the php installation directory, I found out there is NO php.ini.当我查看php安装目录时,我发现没有php.ini。 There are two files php.ini-development and php.ini-production .有两个文件php.ini-developmentphp.ini-production Just rename one to php.ini只需将其中一个重命名为php.ini

Then you should see the correct ini path when you do php --ini然后你应该在执行php --ini时看到正确的 ini 路径

  • Set the extensions directory设置扩展目录

Afterwards, open the php.ini file and uncomment the following line ;extension_dir = "ext" should be然后,打开 php.ini 文件并取消注释以下行;extension_dir = "ext"应该是

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) (但请从您​​从 composer 命令中看到的消息中找出您需要的内容)

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

I was running php7.2.x on my Windows 10 machine before I upgraded to PHP 7.4.10 (cli)在升级到PHP 7.4.10 (cli)之前,我在 Windows 10 机器上运行 php7.2.x

When I first pulled up the php.ini file, to my surprise, it was empty.当我第一次打开 php.ini 文件时,令我惊讶的是,它是空的。

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:我查看了 XAMPP 的php文件夹,注意到两个文件:

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

I copied the contents of the first file and pasted in my php.ini file.我复制了第一个文件的内容并粘贴到我的 php.ini 文件中。 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:然后我进入我的 php.ini 文件的动态扩展部分,不得不取消对以下所有扩展的注释:

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.然后在保存我的 php.ini 文件后重新启动 Apache 服务器。

This time, everything worked!这一次,一切顺利!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM