PHP 无法与 Composer 连接

PHP 无法与 Composer 连接

我的 PC 无法使用 PHP 和 Composer 访问某些网站,例如 Composer 网站。为了安装 Composer,我不得不使用 VPN,但我并不喜欢,因此想找到解决方法。我在笔记本电脑上安装了 XAMPP(与这台 PC 分开),Composer 安装成功,没有显示任何错误。我该如何修复这台 PC,让它像我的笔记本电脑一样工作?

curl -vvv 结果:

curl -vvv https://getcomposer.org/versions
* timeout on name lookup is not supported
*   Trying 2001:41d0:a:7b19::2...
* TCP_NODELAY set
* Connected to getcomposer.org (2001:41d0:a:7b19::2) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: C:/laragon/bin/git/mingw64/ssl/certs/ca-bundle.crt
  CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* NPN, negotiated HTTP1.1
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Unknown (67):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: C=DE; L=Berlin; O=Packagist Conductors UG (haftungsbeschränkt); CN=getcomposer.org
*  start date: Jul 12 00:00:00 2017 GMT
*  expire date: Aug 25 12:00:00 2020 GMT
*  subjectAltName: host "getcomposer.org" matched cert's "getcomposer.org"
*  issuer: C=US; O=DigiCert Inc; CN=DigiCert SHA2 Secure Server CA
*  SSL certificate verify ok.
> GET /versions HTTP/1.1
> Host: getcomposer.org
> User-Agent: curl/7.53.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx
< Date: Tue, 25 Jul 2017 20:59:10 GMT
< Content-Type: application/json
< Content-Length: 317
< Last-Modified: Tue, 25 Jul 2017 20:55:08 GMT
< Connection: keep-alive
< ETag: "5977b02c-13d"
< Accept-Ranges: bytes
<
{
    "stable": [{"path": "/download/1.4.2/composer.phar", "version": "1.4.2", "min-php": 50300}],
    "preview": [{"path": "/download/1.4.2/composer.phar", "version": "1.4.2", "min-php": 50300}],
    "snapshot": [{"path": "/composer.phar", "version": "189ba423aedc387a0487df40afc2428947406327", "min-php": 50300}]
}
* Connection #0 to host getcomposer.org left intact

有时可以连接,但大多数时候都不能。它在我的笔记本电脑上总是可以工作,但在 PC 上却不行。

答案1

由此 线:你可以将其添加到你的 composer.json 中 { "repositories": [ { "packagist": false }, { "type": "composer", "url": "https://packagist.org/" } ] }

相关内容