创建项目laravel错误packagist.org

时间:2018-11-25 13:58:14

标签: laravel composer-php install

当我使用创建项目时 composer create-project --prefer-dist laravel/laravel project 像这样的错误 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。 我搜索了什么问题, 但是大多数问题是update composer和何时必须更改url包。但我想做一个新项目。 enter image description here 我该如何解决。

1 个答案:

答案 0 :(得分:0)

首先,运行:

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

然后,在[home]目录中编辑config.json,使其如下所示:

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

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

{
  "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": {
      "type": "composer",
      "url": "https://packagist.org"
    }
  }
}