Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phing and Composer, which way around?

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?

like image 528
Sander Marechal Avatar asked May 31 '12 07:05

Sander Marechal


2 Answers

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.

like image 187
Seldaek Avatar answered Sep 24 '22 02:09

Seldaek


Additional thoughts about this topic.

Generally Seldaek is right that both are possible. There are arguments for phing first too, though. On the level of build architecture I think composer first doesn't make sense. The build process has broader scope and longer lifetime and should therefore manage the dependency manager, not vice versa.

Furthermore, if you work with Phing token replacement to determine what dependency versions you want to install in which environment, it's close to impossible to go composer first because phing will generate the composer.json and must therefore be installed before composer can run.

like image 30
markus Avatar answered Sep 25 '22 02:09

markus