Phing and Composer, which way around?

Sander Marechal picture Sander Marechal · May 31, 2012 · Viewed 7.3k times · Source

I want to use both Phing and Composer for my applications. Phing as the build system and Composer to manage dependencies. But which way around should they be used?

Currently we're installing Phing globally on all servers. Phing is supposed to completely automate the build of our various projects. Just checkout a copy of the project, run Phing with the default target and you should be good to. This also implies that there should be a Phing target in there that calls on Composer to install all dependencies. So, Phing calling composer. But I have been unable to find anything about this setup. There's no ComposerTask or anything similar and googling around doesn't reveal anyone working that way.

But I do see a lot of it the other way around. People using Composer to install Phing as a project dependency.

So, what are the (dis)advantages of each method? Am I trying to do it from the wrong way?

Answer

Seldaek picture Seldaek · May 31, 2012

I think the main advantage of installing phing via composer, is that for open source projects it's easier to make sure your users have phing installed that way. Typically in those setups phing is just a tool used by some libraries to achieve some tasks.

The other advantage is that every project can use a different version of phing, which you can't do if you have a system-wide one.

If you use phing to manage your entire project build/setup, calling composer from it might make sense, but the other way around as well. For example you could use composer scripts to fire off the phing tasks after every dependency update. That way a project setup would be:

  • checkout
  • run composer
  • composer runs phing after updating/installing deps
  • project is built

I honestly don't know if there is a right answer. You can make both ways work, but by doing it this way you at least skip having to install phing first. Obviously you need to install composer instead, but arguably that's easier and you'd need it anyway.