问题
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
回答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
回答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:
- php.ini-production.ini
- 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!
来源:https://stackoverflow.com/questions/52594477/composer-not-working-on-windows-gives-composer-exception-nosslexception-error