Useful Snippets

Welcome!


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

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at Unwanted.cloud

RSS Latest posts from my personal blog


Subscribe to RSS feed


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

Full-stack impostor syndrome sufferer & Software Engineer at Schibsted Media Group

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.