ANT support in PHP projects

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?


i have been quite happy using phing ( 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 02: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 05:51 AM 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
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 10:58 AM 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 07:40 AM CEST #

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

Posted by a0 on July 31, 2009 at 08:16 AM 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 02: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 10:38 AM 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 17, 2009 at 07:21 PM CET #

This doesn't seem to work in 6.8. I went to Tools->Plugins and searched on 'ant' but the closest I got was Ant Documentation. Furthermore, I only had about 40 available plugins as opposed to the 86 shown in the screenshot. Am I missing something?

Posted by Joe Song on January 26, 2010 at 08:18 AM CET #

ANT is already installed if you use the netbeans-java or all-in-one-version, like many other plugins, propably that's why only see 40 available plugins because the others are installed already.

Posted by robo47 on February 06, 2010 at 07:15 AM CET #

Try renaming your build.xml file to build.ant file.

Posted by BM on July 22, 2010 at 01:30 PM CEST #

BM's solution worked for me (rename to build.ant). I've never seen the .ant extension used before though; always build.xml (I'm a little new to ANT so maybe that's why). Kind of sucks to have to break the build.xml convention

Posted by Daniel on July 29, 2010 at 11:10 PM CEST #

@Daniel rename to build.ant and then back to build.xml it worked for me :)

Posted by Katsuke on August 27, 2010 at 01:13 PM CEST #

Hi, works really fine in a PHPProject :) Many Regards Chris

Posted by Chris on May 09, 2011 at 05:56 AM CEST #

The Ant-Plugin doesn't seem to be available for Netbeans 7.1 - That's a pitty since it worked very well for bigger projects of mine...

Posted by guest on February 27, 2012 at 08:40 PM CET #

Phing support would be even more useful

Posted by guest on June 17, 2012 at 09:57 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed

This blogs is written by NetBeans developers who contribute to the PHP support mainly.


« April 2014