Useful Snippets

Useful Snippets


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

July 2020
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories


Disable GitHub API in Composer to improve speed

Stanislav KhromovStanislav Khromov

If you are using GitHub repositories in Composer, you might notice that it takes a long time to run composer update. This is because Composer uses the GitHub API in an effort to improve performance. Unfortunately, GitHub API is very slow and you might need hundreds of calls for a single repo, depending on the number of tags. You can disable this behaviour by specifying the undocumented no-api flag in Composer. In composer.json, add it like this:

{ 
    "type": "vcs", 
    "url": "git@github.com:user/repo.git", 
    "no-api" : true 
}

This will make Composer check out the repository via Git instead, usually improving composer update times by 2-3x.

Discussion on Reddit with more info on the technical details

More information regarding the no-api flag

Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
LinkedIn
Twitter
WordPress.org Profile
Visit my other blog

Comments 2
  • Justin
    Posted on

    Justin Justin

    Reply Author

    So you can only do this for private repos? or is there also an undocumented cli flag that would prefer no-api for all the things?


    • Stanislav Khromov
      Posted on

      Stanislav Khromov Stanislav Khromov

      Reply Author

      You can do this for any GitHub repo, public or private. But you have to configure the `no-api` flag for each repo in your `composer.json` file.