Handling Composer “lock file out of date” Warning

Composer is dependency management for PHP, and it consists of two main files:

  • composer.json where you specify your dependencies
  • composer.lock where composer itself records exactly which precise version of every library and every dependency of every library it picked, so all installs will be identical

Crucially, the composer.lock also includes a hash of the current composer.json when it updates, so you can always tell if you’ve added a requirement to the composer.json file and forgotten to install it. Continue reading

Using Composer Without GitIgnoring Vendor/

Recent additions to the joind.in API have introduced some new dependencies so we decided we’d start using Composer to manage these – but we don’t want to run composer unsupervised. I’m sure this will bring the rain of “just run composer install, it’s probably mostly almost safe” criticism, but actually it’s quite tricky to run Composer without excluding vendor/ from source control so I thought I’d share how we did it so that anyone who wants to do so can learn from my experience!
Continue reading

Use a GitHub Branch as a Composer Dependency

My current project sees Celery (a python distributed task queue) added to my PHP application. There’s a handy PHP interface to the RabbitMQ that Celery uses as a backend, which makes it easy for me to create jobs, called celery-php. This requires either the PECL AMQP extension or alternatively it has experimental support for the PHP library for AMQP – I would normally prefer the PECL version but ran into version compatibility problems, missing manual pages, and decided that a pure PHP solution might be more portable and perhaps I would just add the experimental branch to my composer.json file for this project. Continue reading

Using Composer in an Existing Project

I’ve got an application (okay, scratty PHP script) which glues together some API things and shows them onto a dashboard for me. Recently, I updated it to use Guzzle as the consuming client, since twitter now needs me to authenticate (I wrote about that if you’re interested), and I used Composer to bring the new library in. It was very simple so I thought I’d share it as it’s quite minimal example, and those are my favourite kind. Continue reading