作曲者内容长度不匹配

作曲者内容长度不匹配

本文介绍了作曲者内容长度不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,当我运行composer update来升级laravel项目时,可能会发生内容长度不匹配的异常.最后,我明白这是因为中国的防火墙太糟糕了:DNS被毒害了.因此,如果您像我一样,是否有办法将其解决?

Sometimes when I run composer update to upgrade the laravel project, a content-length mismatch exception might occur.Finally, I get this is because of the terrible firewall in China: the DNS was poisoned.So, if you are like me, could there be a way to fix it out?

推荐答案

首先,运行:

composer config --list --global          //this will get the composer home path.
[home] /root/.composer                   //it's my composer home path.

然后,编辑config.json,使其如下所示:

And then, edit the config.json, make it like this:

{
  "config": {
    "github-protocols": [
      "https"
    ]
  },
  "repositories": {
    "packagist.org": {
      "type": "composer",
      "url": "https://packagist.org"
    }
  }
}

这将使packagist连接强制为https.而且您还可以在项目中配置composer.json,这是一个laravel示例,如下所示:

It will make the packagist connection force https.And also you could config the composer.json in your project, this is a laravel sample would be look like:

{
  "name": "laravel/laravel",
  "description": "The Laravel Framework.",
  "keywords": [
    "framework",
    "laravel"
  ],
  "license": "MIT",
  "type": "project",
  "require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*"
  },
  "config": {
    "preferred-install": "dist"
  },
  "repositories": {
    "packagist.org": {
      "type": "composer",
      "url": "https://packagist.org"
    }
  }
}

更新

在Composer v1.2.3 之前,packagist的存储库密钥为"packagist".在 v1.2.3 中,它已更改为"packagist.org"(请参阅commit e38ebef ).

Update

Before Composer v1.2.3 the repository key for packagist was "packagist". In v1.2.3 it was changed to "packagist.org" (see commit e38ebef).

这篇关于作曲者内容长度不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 02:01
查看更多