运行 php 和 OSX 下的作曲家导致超时错误

Running php and composer under OSX results in timed out error

我在 运行 php 中使用 Homebrew,在 OSX 中使用 composer。为了开发我的 php 应用程序,我使用 Valet。每次我需要一个包或更新我安装的包时,我都会收到此错误:

The "https://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Operation timed out Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info

我已经尝试了几种解决方案(允许"secure-http":false、更改存储库-url 等)。

但似乎没有什么全球性的工作。使用 secure-http 标志有时会起作用,但脚本需要很长时间才能完成(例如安装新的 laravel 项目)。

有没有办法永久解决这个问题?

问题是由我的 Wi-Fi 连接网络设置中激活的 IPv6 引起的。

这里是 Link to the composer-website.

简单的处理方式:

  1. 为您使用的连接停用 IPv6 networksetup -setv6off Wi-Fi
  2. 运行 你的作曲家命令
  3. 为您使用的连接重新激活 IPv6 networksetup -setv6automatic Wi-Fi

如果您的计算机上不需要 IPv6,您可以将其禁用。