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

4

19

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?

Jingo answered 8/3, 2009 at 5:0 Comment(3)
The link to php|architect magazine is not working :(Choirboy
@Choirboy looks like it changed since I posted the question 10 months ago... Fixed now.Jingo
@ LittleBobbyTables, Michael Berkowski, Rob, CL., Linus Kleen: 8K views + 17 Votes not constructive??Unmoor
D
7

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
Diadiabase answered 8/3, 2009 at 8:39 Comment(2)
Do phing.ant handle database migrations natively, or do they integrate with an external tool?Jingo
Usually an external tool. (Depends on what you mean by "migrations" actually).Diadiabase
C
6

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

Carlsbad answered 16/10, 2012 at 12:13 Comment(0)
B
2

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.

Baskin answered 8/3, 2009 at 7:28 Comment(2)
I think the "implemented in PHP" argument is a bit overrated. It was the exact reason why we choose Phing in the first place but after 3 yrs we never made any changes to the core of Phing. Ant on the other hand is more mature/larger community and integrates nicely with PHP scripts if needed.Diadiabase
Keep in mind that, for some of us, it's dependencies that are important, not modifiability. We just don't want to have to install all that Java stuff when we don't use any Java elsewhere.Tenedos
H
2

On a project I'm working on now we're using phpUnderControl to run tests and get fast feedback when something's broken. We plan to use it to run other tests as well such as some written in Watir.

Hogback answered 8/3, 2009 at 15:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.