title: Continuous Integration using composer
body: <p>I have a PHP project in which I load packages through Composer. I also run Continious Integration using Jenkins, on a dedicated CI server. Once every hour, Jenkins queries my repository for changes, and if present, if executes a test run.</p>
  
  <p>First step of the testrun is making a fresh checkout of the repository, and performing a build of the application, using Phing. One of the steps of the build is performing an</p>
  
  <pre><code>composer install
  </code></pre>
  
  <p>Since Jenkins always works with a fresh checkout, composer will always fetch all packages on every test run, even if none of the packages have been changed since the previous run. This has a couple of disadvantages:</p>
  
  <ul>
  <li>It takes a relativally long time to complete a test run (composer needs to fetch for example Zend Framework, which is rather large</li>
  <li>It put unnecessary strain on the packagist server, if new packages are fetched every hour</li>
  <li>If, for some reason, the composer install fails, so does my test run.</li>
  </ul>
  
  <p>I was thinking of possibly storing the packages that composer fetches on a central spot at the CI server, so Jenkins would be able to access the packages at that location for every test run. Of course, now I have to rewrite part of my application to handle the fact that the vendor folder is in a different location when on the CI server. Secondly, I have to tell Jenkins to keep track of changes on the composer.lock file, to see if he needs to run composer anyway. I'm afraid none of those two things are really trivial.</p>
  
  <p>Does anyone have any suggestions of a other/better way to do this, or is it the best option to just fetch all packages through composer on every test run. Admiditally, it's the best way to make sure you always use the correct packages, but it sortof feels like a waste of bandwith, certainly in later stages of development, when the list of packages will hardly change anymore.</p>