Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP build/integration tools: Do you use them? [closed]

After reading the "Modern PHP workflow" article in the November 2008 edition of php|architect magazine which discussed unit testing (phpUnit), build tools (Phing) and continuous integration (Xinc), I'm inspired the learn more about some of the tooling available for PHP, especially Phing.

In the past I've often handled deployment to a production server by running the live site as a subversion working copy and simply running an "svn update" on the production box to deploy the latest version of the code.

Do you use build tools for PHP code? What advantages you you believe they offer over deploying direct from subversion? What should I look out for, or what gotchas might I face?

like image 838
Jim OHalloran Avatar asked Mar 08 '09 05:03

Jim OHalloran


3 Answers

I have used both Phing and Ant and prefer the latter much more. I initially went with Phing due to it being written in PHP but to be honest it isn't as mature as Ant. In the end, having a mature buildsystem with a large community is worth more.

Things done with Ant/Phing:

  1. From a base checkout loalize to a specific language, ensure dependencies are there (other libs, directories, etc)
  2. if you have them, compile templates, etc
  3. Bring target database up to the required version, depending on the checked out code version
  4. run unit tests, etc
like image 145
Jilles Avatar answered Oct 24 '22 06:10

Jilles


A large issue that I see with Phing is that it creates a needless layer of indirection. PHP is a scripting language, and therefore could be run directly. Phing's use of XML configuration is a poor fit for the language: it does provide a more readable declarative configuration, but at the cost of sacrificing any of the flexibility of the language. With Ant (the inspiration for that route) it makes sense since Java did not have that flexibility as it is less dynamic and requires compilation.

Unfortunately I haven't seen many good alternatives in the PHP space, and unlike other languages build tools are not as essential or a part of the culture so the evolution of another well supported option may not happen any time soon.

I'd therefore stick to options that are closer to what PHP could do from cultures that more aggressively support build tools. I normally use Gradle. Rake also does a great job depending on with which language you want to cheat (and there may be other similar options). You should also weigh things like Webdriver support if you're into that type of thing. Otherwise creating a lightweight solution using PHP and/or BASH should cover everything while maintaining transparency

like image 7
Matt Whipple Avatar answered Oct 24 '22 05:10

Matt Whipple


I looked at at Phing at it looks pretty awesome. For the project I'm working on I'm actually using Apache's Ant. I use it to do a several things:

  1. Combine and compress Javascript and CSS (compression done using the YUI Compressor
  2. Replace standard config files with production config files (e.g. rename config.php.production to config.php)
  3. Remove un-needed files (such as the ant build file, build.xml)

I think Phing is worth looking at over Ant because it's native PHP, which could be nice. Also if you are doing anything more than just copy/moving files around look out for performance issues when you move to the production environment. I had an issue where the YUI compressor ran fine on my local machine but on the relatively small VPS it was super slow.

like image 2
Brian Fisher Avatar answered Oct 24 '22 05:10

Brian Fisher