Generating PHP documentation from NetBeans 6.5

NetBeans 6.5 doesn't have direct support for generating PHP documentation. Here is a trick how to do it. Basically I use a new Run Configuration that calls a small script to generate the documentation. I did this on my Ubuntu machine, but Windows users should be able to reuse the steps.

At first I downloaded the PHPDocumentor itself from the project pages, unzipped the zip file and change the rights of phpdoc to be executable.

For the next step I created a new bash script which I call from NetBeans. You can write the script directly in NetBeans. NetBeans PHP distro  includes very simple syntax coloring support for bash script and bat files as well. The picture below displays NetBeans PHP RC2, showing my script that I use for generating the documentation.

The text form of the script:

#! /bin/bash
# Script for generatig php documentation from NetBeans through run configuration

$PATH_TO_PHP_DOCUMENTOR/phpdoc -d $2 -t $3
echo "Generating PHP Documentation finished ..."
firefox $3/index.html

As you can see the script is very simple. If you want to use it, you should just change the value of PATH_TO_PHPDOCUMENTOR variable to pick up the phpdoc script from your location. Through the -d parameter you define which directory will be parsed (and subdirectories) and -t parameter says in which directory the PHPDocumentor should create the documentation files. When the generation of the documentation is finished than the result is opened in new Firefox tab to check the result.

Now, when the script is done, I need to call it from NetBeans. As I have mentioned we can use for this new Run Configuration. There are three ways how to display Project Properties dialog where you can create it. You can select the project node and in the context menu over this node invoke Properties item or from main File menu choose Project Properties item or in the main tool bar there is combobox with already existing configurations and the last item in the combo box is Configure... item. The combo box in the main tool bar is a way how to quickly switch between configurations.

So in the Project Properties dialog click on the Run Configuration category and create new configuration through the New... button. I have named the configuration PHPDocumentor. In the Run As combo box select Script (run in command line) item. Uncheck Use default PHP Interpreter and browse the created script. As the first argument put the path of your project sources. You can copy the path from the Source category panel, Source Folder text field. As the second parameter put a path, where you want to generate the documentation. The folder doesn't have to exist, the PHPDocumentor will create it. The picture below shows my PHPDocumentor configuration.

NetBeans will put for the script as the first argument the Index File, when you run project with this configuration or the file for which you invoke Run Single File action. This parameter is in my script simply ignored and always the documentation is generated for all sources.

Now when I choose the PHPDocumentor configuration in the combo box in the main tool bar and run the project,  then the documentation is generated and the result is opened in new Firefox tab.

You can improve the script and add more parameters, it's all up to you. I know that this is not the ideal support of PHPDocumentor, but for the next verion I want to make the real integration. If a Windows user out there will write the bat file, could you please attach the file in a comment, and I will alter this post.


Hi Petr,

This looks great and can be used until full integration is possible.

What about ScriptDoc? It would be great if we could genearate documents for both JavaScript and PHP. I think ScriptDoc can handle both.

Posted by raymond on November 05, 2008 at 12:41 PM CET #

Thank For great Post,Generating PHP documentation from NetBeans 6.5,This article really more informative and very helpful information for Php programmer Thank for grate information............

Posted by PHP Development at India on July 09, 2009 at 05:25 AM CEST #

Thanks for your help, we are searching for the script, all the best, keep the good work

Posted by Premium web templates on July 17, 2009 at 01:40 AM CEST #

it is really helpful for developers - thankyou

Posted by web development in php and mysql on July 17, 2009 at 01:45 AM CEST #

Perhaps my English is bad, but after several trying, I have only a blank page !!
I'm sure this Tutorial is good, and I'm sorry to can't manage to run it.
Where can I have help ?



Posted by Laurent on August 22, 2009 at 05:56 PM CEST #

Great, it works on Windows XP too. My environment is NetbeansPHP 6.8M1 with XAMPP 1.7.2

step 1) I have installed PhpDocumentor via XAMPP shell (xampp_shell.bat) using command:
pear install --alldeps PhpDocumentor-1.4.3

step 2) I have created phpdocNB.bat:
C:/xampp/php/php.exe C:/xampp/php/PEAR/PhpDocumentor/phpDocumentor/ -d %2 -t %3
echo "Generating PHP Documentation finished ..."
"C:\\Program Files\\Mozilla Firefox\\firefox.exe" file://%3/index.html

step 3) I have created "Run Configuration" according to Petr´s screenshot.

Good luck

Posted by Jozef on September 08, 2009 at 03:03 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 29, 2009 at 08:22 PM CET #

Unfortunatetly this option doesn't seem to work under Netbeans 6.8 + MAC OS X Snow Leopard :(

Any ideas?

Does anyone know when or if netbeans has any plan to integrate PHPDocumentor?

Thank you very much.

Posted by Carlos Fernández San Millán on December 17, 2009 at 01:21 AM CET #

The integration of PHPDocumentor is also on my list. From the implementation point of view it should be easy, only my problem is the time.

Posted by Petr Pisl on December 17, 2009 at 08:09 AM CET #

I have question too. How to embed this help into context help CTRL + SPACE.
Please reply

Posted by Janos on March 05, 2010 at 10:59 AM CET #

To Janos:
Basically NetBeans doesn't use the result html pages in context help. What you see, comes from php sources or from the signatures files that has to be on the project include path.

Do you have just the PHP doc in html form?

Posted by Petr Pisl on March 11, 2010 at 08:40 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed

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


« July 2016