:::: MENU ::::
Posts tagged with: continuous integration

Tip: Fix Composer package 404 errors with continuous integration servers

Is PHP’s composer package manager pulling in dependencies successfully on your development machine but failing on your continuous integration server? In my case, Drone.io, the young, ludicrously simple CI platform, was failing in setup of a PHP project because of strange 404 “Not found” errors.

drone.io illustration

drone.io’s bug hunting, er, drone

The solution is to use a flag with your “composer install” command: composer install  --prefer-source

The explanation is that composer users GitHub’s API to fetch packages, and it uses it anonymously by default. Anonymous users have a strict call limit – 60 per hour per IP. That means that for a hosted CI, only 60 calls can be made to GitHub for potentially thousands of customers. When the limit is reached, GitHub returns 404 (not the most helpful error given the context).

Thanks to Pagoda Box for researching this solution.