ANT support in PHP projects

Posted by Petr Pisl on Dec 02 2008, 09:06:01 AM CET

A build tool can be used for automated actions. For example if you want to have continual build and run tests, building documentations, create a production builds, deploy on a staging or production server etc. One of such build tools is Apache Ant, which  is a Java-based build tool. You can use this tool also together with your PHP projects. The NetBeans PHP distribution is probably only one distribution, which doesn't contain the Ant support by default.

Adding Ant into the IDE is very simple. Open the plugin manager (Tools->Plugins) and on the Available Plugins tab in the Search dialog write ant. After this, you should see similar picture to:

Check the Ant item and click on Install button. After accepting the license, the needed module are downloaded from the update center and installed. If you have already an ant file in your project it should be after the installation recognized.

Although the Ant files are xml files, they have a special icon in NetBeans. You can expand the node that represents the Ant file in explorer and the subnodes are the targets defined in the script. You can run single target and also you can assign a shortcut for a target through the context menu over the target node.

The editor offers code completion for Ant tags and also for their attributes. You can also validate and check whether the file is well formed.

There is one limitation in PHP distribution. The PHP project doesn't allow to create Ant files through a wizard. So you have to create new well-formed xml document. The root element has to be <project>.

Does someone from readers use Ant together with PHP projects? Do you use a building tool? Which one?

Category: Tips & Tricks | Permalink | Comments [8]

Trackback URL: http://blogs.sun.com/netbeansphp/entry/ant_support_on_php_projects
Comments:

i have been quite happy using phing (http://phing.info). even though it isn't as complete as ant, phing has been quite handy and due to its being written in php quite hackable for php developers. right now i would probably switch to ant (if i had the time) since most projects seem to build upon ant.

Posted by Lucas on December 02, 2008 at 10:40 AM CET #

I use make, bash :-) I know about phing, phing seems good, because is written in php.

Posted by optik on December 02, 2008 at 01:51 PM CET #

I am using Ant more as 8 years with very good results starting with large Java projects and last two years with building of PHP components mostly for CMS Joomla. I tried in PHP environment PHING but unfortunately those days (2006) this tool was not able to manage hierarchical directory tries with more levels (what was my case). I came back to Ant with own tool AntRUN (see http://www.kanich.net/radio/site/joomla-tools/antrun-description).
With some additional external tasks (library ant-contrib-1.0b3) I can manage also complex PHP build with testing and preprocessing.
One remark more NB 6.5 are very well suited for PHP programming unfortunately word-wrap feature for editor (especially HTML code) is badly missing.

Posted by vlado on December 02, 2008 at 06:58 PM CET #

Does it work with Netbeans 6.7 ?

For me, build.xml is not recognized as an ant file but only as a xml file. There is no Ant context menu.

Posted by a0 on July 31, 2009 at 02:40 PM CEST #

Sorry, it is ok with netbeans 6.7, I didn't have put JAVA_HOME.

Posted by a0 on July 31, 2009 at 03:16 PM CEST #

It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader. Thanks again.

Posted by links of london on October 30, 2009 at 09:35 AM CET #

I try to use Ant in the PHP Distribution of Netbeans 6.8 to use YUI Compressor.
But the build.xml file is not seen as an Ant file.

I installed the Ant Plugin as described below. Is there anything else to do ?

Does anyone uses YUI Compressor (with Ant or with somethong else) in Netbeans for PHP ?

Posted by David on November 13, 2009 at 06:38 PM CET #

Like David, I too am having problems with Ant. I mean like just this week recent. I've been using Ant with PHP projects through Netbeans for, I think, about a year and this has not been a problem. I didn't see the place to file a bug, but if someone could follow up with me and provide a bug link, I'll gladly file one.

Posted by Jeremy on November 18, 2009 at 03:21 AM CET #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed