laravel 作曲家:“内容长度不匹配”和“http://packagist.org 无法完全加载...”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40309620/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 14:40:15  来源:igfitidea点击:

Composer: "Content-length mismatch" & "http://packagist.org could not be fully loaded..."

phplaravelubuntudoctrinecomposer-php

提问by Chung

When I try to create a new laravel project with "laravel new project" I got this error:

当我尝试使用“laravel new project”创建一个新的 laravel 项目时,出现此错误:

Content-Length mismatch
http://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date

When I do "composer update" or "composer install doctrine/dbal", I got the error too. And my composer is too slow.

当我执行“作曲家更新”或“作曲家安装学说/dbal”时,我也收到了错误消息。而且我的作曲家太慢了。

回答by Martin

Maybe it is because you have not change you composer's url. I run this in my shell and it's work. And i guess the url is different in different city. Hope it will help you guys.

也许是因为您没有更改作曲家的网址。我在我的 shell 中运行它,它的工作。而且我想网址在不同的城市是不同的。希望它会帮助你们。

composer config -g repo.packagist composer https://packagist.phpcomposer.com

回答by Pegasus

I got this same error and solved it only changing the httpprotocol in composer repository config with https:

我遇到了同样的错误并解决了它,它只更改了httpComposer 存储库配置中的协议https

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

回答by Bastian Haustein

As far as I know, there is a rate limit on the repository per IP. Could it be, that you did a lot of requests in a short time? So just wait a few hours and try again. I had the same problem while trying to automate things with docker and ran the docker script several times.

据我所知,每个 IP 的存储库有一个速率限制。难道,你在短时间内做了很多请求?所以只需等待几个小时,然后再试一次。我在尝试使用 docker 自动化并多次运行 docker 脚本时遇到了同样的问题。

回答by Arthur Tarasov

I get this error when I'm in China. This is what works for me:

我在 CN 时遇到此错误。这对我有用:

  1. Turn on a Chinese VPN

  2. Run composer config -g repo.packagist composer https://packagist.phpcomposer.com

  3. Update your composer

  1. 打开 CN VPN

  2. composer config -g repo.packagist composer https://packagist.phpcomposer.com

  3. 更新你的作曲家