Do you use Phing? [closed]
Asked Answered
J

5

25

Does anyone use Phing to deploy PHP applications, and if so how do you use it? We currently have a hand-written "setup" script that we run whenever we deploy a new instance of our project. We just check out from SVN and run it. It sets some basic configuration variables, installs or reloads the database, and generates a v-host for the site instance.

I have often thought that maybe we should be using Phing. I haven't used ant much, so I don't have a real sense of what Phing is supposed to do other than script the copying of files from one place to another much as our setup script does. What are some more advanced uses that you can give examples of to help me understand why we would or would not want to integrate Phing into our process?

Jejune answered 31/8, 2008 at 5:4 Comment(0)
T
16

From Federico Cargnelutti's blog post:

Features include file transformations (e.g. token replacement, XSLT transformation, Smarty template transformations), file system operations, interactive build support, SQL execution, CVS operations, tools for creating PEAR packages, and much more.

Of course you could write custom scripts for all of the above. However, using a specialized build tool like Phing gives you a number of benefits. You'll be using a proven framework so instead of having to worry about setting up "infrastructure" you can focus on the code you need to write. Using Phing will also make it easier for when new members join your team, they'll be able to understand what is going on if they've used Phing (or Ant, which is what Phing is based on) before.

Timofei answered 31/8, 2008 at 8:22 Comment(0)
L
8

The compelling answer for me is that phing understands PHP classpaths. Ant doesn't. I don't want to have an ant build.xml full of exec commands. I happen to be primarily a java programmer and still use phing. It's the best tool for the job.

Larsen answered 8/6, 2009 at 22:27 Comment(1)
UMMM... for execution of PHP scripts with ANT, all you need is "#!/usr/local/bin/php" (or the location of your php executable) at the top of your PHP script . Then you simply call the script from ANT like you would for any linux command line operation. You can solve any custom code operations, including SQL commands from PHP, that way.Yes
G
7

I moved from Ant to Phing 'just because' it's PHP. I use it to export from different subversion repositories, copy stuff around, build different installation packages, etc all of that with a 20 line reusable xml file and a config file with project specific stuff. No way I could do it that fast with a custom script. I also plan to integrate api documentation generation and unit tests. Love it!

Grayling answered 26/4, 2009 at 9:10 Comment(0)
D
3

We use phing to deploy SemanticScuttle:

  • generate zip archive for distribution
  • create PEAR package
  • upload zip to SourceForge
  • update the PEAR channel with the new package file
  • render reStructuredText documentation into html files and uploading them. Currently with exec but I'm on the way writing a separate task for it.

Uploading the zip file and the channel is done via rsync, which is unfortunately not supported by phing through a special task - but using exec is always possible and works nicely.

In the end, it saves a lot of time and we're able to test, package and deploy our app with one single command (which gives us another point on the Joel Test). I would not want to live without it.

See the build.xml code.

Doane answered 12/6, 2011 at 17:54 Comment(0)
D
2

I don't see any compelling reason to go with phing. I mean, should PHP programmers attempt a rewrite of Eclipse "just because" it might somehow be easier to write Eclipse plugins in PHP? I don't think so.

Ant has better documentation, including some nice o'reilly books, and it's well-established in the Java universe, so you avoid the problems of (1) "we haven't copied feature X to phing yet" and (2) the risk of the phing project going dead. Here's an article on configuring PHPUnit to work with ant and cruisecontrol: not that hard. And you get eclipse integration for free.

Good luck!

Danadanae answered 24/10, 2008 at 21:5 Comment(3)
Well, rewriting Eclipse is probably not the best idea, having Ant port in PHP is really great idea. The reason is simple: custom tasks, that can be done in plain old PHP (not everybody knows Java well enough). Building application, more than often, involves custom functionality that begs to be automated, and ability to do so in language you are proficient at - well, to me it could be considered as a great plus. P.S. If you are using Java, then you probably should look at Maven :))Aziza
Ant's documentation is not better than Phing's. Yes, Phing's docs lack more examples but Ant's do, too.Doane
You do not have to rewritten ANT in PHP in order to build custom tasks. All you need should be an adaptertask or compiler which allows you execute PHP scripts from ANT.Mahler

© 2022 - 2024 — McMap. All rights reserved.