配置 composer 以通过 https 从 packagist.org 获取数据

Configure composer to get data from packagist.org via https

在阻止出站 http 请求的环境中构建文件时,我收到如下错误:

Updating dependencies (including require-dev) The "http://packagist.org/p/provider-2013%ahash.json" file could not be downloaded: failed to open stream: Connection timed out http://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date

有什么方法可以指示 composer 使用 https 连接到 packagist 吗?

我在 1.2.0 和 1.6.5 版本的 composer 上都遇到过这个问题。

您可以通过以下方式强制作曲家使用 https:

composer config -g repo.packagist composer https://packagist.org

或者您可以在 composer.json 文件中设置:

"repositories": [
      {
        "type": "composer",
        "url": "https://packagist.org"
      },
      { "packagist": false }
    ]

Source: issue #5656 on composer's github repository.