Explore Open Source Technology

Lets Explore Power of Open Source Technology PHP, MYSQL, APACHE, LINUX(LAMP)

Apache ANT - Phing Project Website

Posted by openstech on January 8, 2008

PHing Is Not GNU make; it’s a project build system based on Apache Ant. You can do anything with it that you could do with a traditional build system like GNU make, and its use of simple XML build files and extensible PHP “task” classes make it an easy-to-use and highly flexible build framework. 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.

Read More

Posted in linux apache mysql php development, server, web development in php | Tagged: , , | No Comments »

Improve Your Build Process with Ant

Posted by openstech on January 8, 2008

Web applications today are much more complex beasts than they were even just a few years ago. The largest sites may constitute thousands of files with complex directory structures, and migrating those between development, staging, and production environments can be difficult to say the least. My own experience with web applications dates back to 1996. While I’ve seen a lot of changes over the years, keeping a large project in check never seems to get much easier, despite advances in CPU speed, RAM prices, broadband, and communication tools.

A few years ago I started using Ant to help bring some structure to my project’s packaging and maintenance. As always, I kept everything in CVS, but I’d grown tired of making sure that every step I’d outlined happened in the correct order to create a working product. Between copying files, setting permissions, and editing configuration files, I found many times that one simple omission would cost hours of lost time. Using Ant to automate those tasks was the first step in regaining control of the build process.

Ant Is Java
Yes, Ant is a tool written in Java. Many PHP advocates like to defend PHP against other technologies in the web space by claiming, “Use the best tool for the job!” PHP on the Web is a shining example of this. However, I’ve yet to find any tools written in PHP that can do everything Ant can do. The closest I’ve found is a project called Phing, but even this tool lacks some advanced aspects of Ant. (Maybe they’ll catch up!)

How Does It Work?
This article isn’t a complete Ant tutorial–the Ant home page has much more information than I can provide here. Additionally, this article assumes you have Java and Ant installed already.

When invoked, the Ant program looks for an XML configuration file (build.xml by default), which contains the instructions about what tasks to perform. Each set of tasks is a target and has a name in the XML file.

Example Build File
Here’s an example build.xml file:

<?xml version=”1.0″?>
<project name=”Sample Project” default=”init” basedir=”.”>
<description>Example project</description>
<target name=”init”>                 
<property name=”sample” value=”Hello world!”/>         
</target> 
</project>

Assuming the file is in the current directory, type ant at a command line:

Buildfile: build.xml  init:  BUILD SUCCESSFUL Total time: 0 seconds
Ant processed the build file, ran the init target (because it is the project’s default target), and then exited successfully. Now change the file a little more and add a bit of output:

<?xml version=”1.0″?> 
<project name=”Sample Project” default=”init” basedir=”.”>         
<description>Example project</description>          
<target name=”init”>                 
<property name=”sample” value=”Hello world!”/>                 
<echo message=”${sample}”/>        
</target> 
</project>
The output this time is:

Buildfile: build.xml  init:      
[echo] Hello world!  
BUILD SUCCESSFUL Total time: 0 seconds

Posted in linux apache mysql php development, web development in php | Tagged: , | No Comments »