Phing

Changing Memory Allocation In Phing

Running complex tasks in Phing can mean running out of memory, especially when altering or changing lots of files. I was recently working on a image sorting Phing project that sorted images based on EXIF information. The many thousands of files involved, along with the custom target used to extract the EXIF data caused the default available memory to run out quite quickly.

philipnorton42 Wed, 08/07/2013 - 12:36
Listing Phing Targets In A Project

Providing a Phing build file along with a project is a good way of allowing automation of certain aspects of the project. The only trouble is that users won't know what's in the build file unless they open it or just run it. You could provide documentation along with the build file so that users know what to use the file for, but a better approach is to list out the targets available in a project. This can be done easily by using the -l (lower case L) or list flag, which will just list the available targets in the supplied build file.

philipnorton42 Fri, 06/28/2013 - 17:05
Control Structures In Phing

Phing has a few different tasks and elements that allow you to select paths of code execution depending on what you need to happen in a build file. These are limited to loops and if statements, but a lot of functionality can be covered with just a couple of lines of XML.

philipnorton42 Sun, 06/02/2013 - 11:52
Source Controlled Git Hooks With Phing

The other day I was experimenting with Git hooks. These are scripts that you can execute before certain actions are run in Git. For example, you might want to ensure that forced updates are not run, ensuring respository files have the correct permissions after merging, or that the files have ASCII standard names before being committed.

philipnorton42 Sat, 05/11/2013 - 00:15
Detecting The Sudo User In Phing

I use Phing for a lot of different tasks, it helps me to automate things that I would otherwise mess up if left to my own devices. Prime candidates for Phing scripts are things that I don't do that much and forget how to do them, or that have a number of complex steps. The only problem I have found is that because many of the Phing scripts I create rely on system changes (eg, configuring an Apache server) they therefore require system changing privileges. Normally I would just prefix the Phing command with sudo, but every now and then I forget all about that step and the build fails.

philipnorton42 Wed, 04/10/2013 - 20:50
Checking Syntax Errors In PHP And JavaScript Using Phing

Checking Syntax Errors In PHP And JavaScript Using Phing

Running a simple syntax check over your files is a good way to save time. This can be when testing code but best practice is to not to even commit code that contains syntax errors.

You can syntax check a single file using the -l (lowercase L) flag with the PHP executable like this.

philipnorton42 Mon, 10/29/2012 - 21:26
Using Phing To Create Apache Virtual Hosts

Phing is an awesome tool for automating things and I use it more and more for automating all kinds of different tasks. One of the tasks that I don't tend to do all that much is setting up a new local virtual host for Apache on my development machines. I know how to do it, but there is always something I forget to do, or a convention that I don't follow which means that I have to repeat myself at a later date to fix something I have missed.

philipnorton42 Fri, 04/06/2012 - 20:11
Adding A Context Menu Item For Phing On Windows

To make things a bit quicker when using Phing on Windows use the following registry entry to create a right click option that integrates with Phing.

philipnorton42 Wed, 03/21/2012 - 15:29
Using SSH and SCP in Phing

Phing allows the running of SSH commands on servers and the copying of files to servers via SCP. Before you can use SSH and SCP commands in Phing you need to install the PECL extension SSH2. The SSH2 PECL extension requires the libssh2 package, so you need to install that before you can get started. The following install instructions are based on a Linux environment.

Download the libssh2 package from www.libssh2.org and install it by using the following commands. Your package version may vary.

philipnorton42 Sat, 10/29/2011 - 21:32
Getting Time And Date Values In Phing

The tstamp task in Phing can be used to generate a timestamp that can be used anywhere within the current project. The default behavior of tstamp is to create the properties DSTAMP, TSTAMP and TODAY, which contain time and date values. All you need to do is include the tstamp XML tag in your project somewhere.

  1.  

The properties DSTAMP, TSTAMP and TODAY use the PHP strftime() function as a basis for formatting the time. The following table shows the value of each property.

philipnorton42 Fri, 06/10/2011 - 16:43