Phing

Posts about the PHP build package Phing

Create Compressed Files With Phing

Thursday, January 15, 2009 - 11:27

Building your projects into directories is nice, but distributing these projects is difficult if you have to build the compressed files yourself. Phing has the ability to create zip and tar files using simple commands.

The most convenient way of using the tar and zip commands is by using a fileset. But rather than use the fileset that was used to copy the files into the build directory it is best to create a separate fileset that is used to compress the contents of the build directory.

Category: 

Create A File Or Directory With Phing

Wednesday, January 14, 2009 - 15:56

After following the last post on deleting files and directories in Phing you might now be wondering if you can create things as well. The answer is yes.

To create a directory with Phing you need to use the mkdir element. The dir attribute is used to give the name of the directory to be created. The following example will create a directory called myProject_build in the current working directory (ie. where you are running phing from).

Category: 

Deleting Directories With Phing

Tuesday, January 13, 2009 - 16:14

Although using Phing is mainly about copying files, you might also need to delete directories and files using the delete element. Remember that the default behavior of copy command copies files only if the source files are different from the destination files. A prudent approach might be to delete the build directory and then recreate it, ready for Phing to copy files into.

Category: 

FilterChain Element In Phing

Monday, January 12, 2009 - 17:49

The FilterChain element is where the power of Phing really comes into its own. This element will allow you to change the contents of the files of a fileset. This can range from a simple stripping of comments, to replacing values and numerous other filters.

One of the simplest thing that can be done with filterset is to strip all comments from the files in question. Take the following PHP file with two comments.

Category: 

Built In Properties In Phing

Friday, January 9, 2009 - 10:53

Aside from assigning and using your own properties Phing also comes with a set of built in properties that can be used to find out all sorts of information regarding the system that Phing is run on.

As an example, lets say you wanted to found out the operating system that phing is being run on. In this case you would use the variable host.os, which on a Windows XP system would print out WINNT.

Category: 

Using Custom Properties In Phing

Thursday, January 8, 2009 - 12:25

Phing allows you to set up certain parameters that can be used throughout the rest of the script. These might be used to define a non standard build directory, or to store database connection details that can be written to the connection file during the build.

Properties are defined using the property element, which you should place at the top of your build.xml file in order to make it easy for other developers to see what is going on. The following example defines a property and the uses the main target to print the property out.

Category: