Skip to content

Instantly share code, notes, and snippets.

@anisur3036
Forked from oanhnn/how_to.md
Created March 7, 2020 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anisur3036/c1d0768079b6288e68d0ce1d03a1431b to your computer and use it in GitHub Desktop.
Save anisur3036/c1d0768079b6288e68d0ce1d03a1431b to your computer and use it in GitHub Desktop.
How to fix composer error "Content-Length Mismatch"

First, run:

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

And then, edit the config.json in [home] directory, make it like this:

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

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

Source: http://stackoverflow.com/questions/38635257/composer-content-length-mismatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment