X

An Oracle blog about NetBeans for PHP

Generate PhpDoc

Guest Author

Today, I would like to show you how one can generate documentation for his/her PHP project. Fortunately, it is a very simple task in NetBeans. First, validate in IDE options that your PhpDoc installation was recognized and that the PhpDoc script has been found. If not, find it manually:

PhpDoc Options

If everything is OK, then just generate documentation via project's context menu:

Generate PhpDoc

 If it is the first time you invoke this action for the current project, NetBeans asks you where to generate files for this project:

Select a Directory for Documentation

Then, the documentation itself is generated and of course, one can review the whole process in the  Output window:

Output Window

If anytime later the documentation directory needs to be changed (or one wants to change the documentation title), it can be easily done in Project Properties dialog:

PhpDoc Properties of a PHP Project

That's all for today, as always, please test it and report all the issues or enhancements you find in NetBeans Bugzilla (component php, subcomponent PHPDoc). Please notice that if you write a comment here but do not report a bug or enhancement, nothing will probably happen ;)

Join the discussion

Comments ( 27 )
  • Tom Monday, August 9, 2010

    So: this is an extension that issues a command line call with some arguments. Arguments of a third-party tool which's names or syntax may be subject to change - even though we may consider them as stable for now. Also - as you support just a subset - just the ones I need may be missing, or there might be some behavior you haven't foreseen.

    Wouldn't it be easier to implement just one single plug-in that issues user defined command line calls on a click and be done with it?

    Then you wouldn't have to implement a new functionality whenever you feel like you need to support another third-party feature.

    Instead you just drop in a new Ant-file and that's it. No more need for any coding at all. Never, ever again. And best thing is: users can add these themselves.


  • Tomas Mysik Monday, August 9, 2010

    To Tom:

    I could be wrong but I think that you have already written about missing "External Tools" feature; if yes, feel free to submit an enhancement, against "ide"/"Code" (External Tools are not related to PHP area).

    Thanks,

    Tomas


  • TG Monday, August 9, 2010

    Wow coool.... :)


  • Petr Jiricka Monday, August 9, 2010

    To Tom and Tomas: note that there is already a feature request for the generic External Tools support, see this issue: http://netbeans.org/bugzilla/show_bug.cgi?id=35582. Feel free to vote for it.


  • Tom Monday, August 9, 2010

    @Petr according to the Bugtracker this issue was reported 21.08.2003 for NetBeans 3.6. Nothing has changed since back then. 7 years later NetBeans 6.9.1 still does not have this feature.

    In 2009 the task finally became assigned to: none.

    Somehow I don't feel like this will ever be completed. I will give it a vote though.

    Problems remain the same as with previous add-ons to NetBeans. The PHP-Documentor support is a fine feature and nice work. Thanks again for that!

    However: PHPDoc offers a lot more functionality and has a lot more command line arguments as implemented here.

    - custom configuration files per project?

    - selecting custom template packs per project?

    - showing the errors.html file in the logs?

    Also you might want to run a custom bootstrap script. Because you might want to suppress the hundreds of irrelevant E_NOTICEs that PHPDoc issues while running on a server with error reporting set to E_ALL. Otherwise it will clutter up your log console.

    Also some people may want to use multiple configurations per project: to create HTML, PDF and CHM files.

    There is more than meets the eye in that little tool called PHP-Documentor. ;)


  • Otto Tuesday, August 10, 2010

    Hi, any ideas why i'm not seeing the phpDoc tab at the Options dialog?

    i'm using 6.9.1


  • Tomas Mysik Tuesday, August 10, 2010

    To Otto:

    Sure, as written in the blog post, you need the development version of NetBeans. This feature will be present in the next major NB version (NB 6.10), NB 6.9.1 is just bug fix release for NB 6.9 (so no new features).

    Tomas


  • Otto Tuesday, August 10, 2010

    Hi, thats also what i thought - maybe i'm blind but i dont found the sentence that you'll need the development version ;)


  • Tomas Mysik Tuesday, August 10, 2010

    To Otto:

    Sorry, it is probably not explicitly said but it applies for all our blog posts in general.

    Thanks,

    Tomas


  • SandbergPDX Wednesday, August 11, 2010

    I must agree with Otto -- not only is there no mention that this relates to Dev versions of NB, but I was \*really\* unaware that \*ALL\* posts on this blog relate to the DEV versions of NB.

    Some more reader education / notice of such would be really helpful.


  • Tomas Mysik Wednesday, August 11, 2010

    To SandbergPDX:

    Well, have a look at the last paragraph, please. You will see that in order to test this feature, you must follow the link (its titlen is "NetBeans PHP development builds").

    But you are right, we will be more precise next time.

    Thanks,

    Tomas


  • Onno Saturday, August 21, 2010

    I was wondering the same thing as Otto, so I was glad to find the answer here.

    But ... I just have netbeans 6.9.1

    What is the development version?

    Where can I download it (I searched in google, but couldn't find anything about a separate development version...)


  • Rick Charon Tuesday, September 7, 2010

    I just installed 6.9.1 netbeans on Ubuntu 9.10, and don't see any reference to phpdoc anywhere, in options, available plugins, nowhere. The tab for it in the Options/PHP simply isn't there. How do you get this to show up?

    Thanks,

    Rick


  • Thomas Kieslich Friday, September 10, 2010

    Tested under Windows + xampp

    Tools-phpdoc

    C:\\xampp\\php\\phpdoc.bat -o HTML:frames:earthli

    Output:

    ...

    Parsing configuration file phpDocumentor.ini...

    (found in .\\pear\\data/PhpDocumentor/)...

    ERROR: cannot open phpDocumentor.ini in directory C:/xampp/php/PEAR/PhpDocumentor

    -Is phpdoc in either the path or include_path in your php.ini file?

    CMD:

    C:\\xampp\\php\\phpdoc -d /xampp/htdocs/php -t /xampp/htdocs/php/Docs/API -o HTML:frames:earthli

    What can i do?


  • Jeffrey Rubinoff Monday, September 13, 2010

    Onno:

    You can download daily development builds from the main NetBeans installation page, http://netbeans.org/downloads/index.html. Just click the Development link near the top.

    Rick Charon,

    This feature is under development and is only available in 6.10 development builds, as discussed in the 3 comments immediately above yours. :)


  • Petr Pisl Tuesday, September 14, 2010

    To Thomas: Does exist file C:/xampp/php/PEAR/PhpDocumentor/phpDocumentor.ini ?

    Regards,

    Petr


  • Thomas Kieslich Tuesday, September 14, 2010

    @Petr

    no, its in (found in .\\pear\\data/PhpDocumentor/)

    but i make a copy in C:/xampp/php/PEAR/PhpDocumentor/

    restart Apache and Netbeans and i have the same result

    The CMD Version works like charm without the -c Parameter.

    Did i need Phing?

    Regards, Thomas


  • Thomas Kieslich Tuesday, September 14, 2010

    @Petr and people wors on Windows/xampp ;-)

    start in xampp root xampp_shell.bat

    cd php

    pear channel-update pear.php.net

    pear install --alldeps PHPDocumentor

    After install from the shell it works grat. Thanks for this nice Feature.

    BTW: the same procedure for phpunit ;-)


  • zehbaeh Wednesday, September 15, 2010

    Supporting Frameworks.

    I am using Ant to support my own Framework (including doc generation).

    Unfort. i did not managed to get the path of the most recent edited file/node in the IDE.

    If have Read about "org.netbeans.api.editor.EditorRegistry", which seems to be the right class for the described pursose.

    If we can get an easy to use Ant-Module which exposes the PHP-Project and parts of the IDE (like the EditorRegistry) some of us might get happy without any further Framework support in the Future.


  • n3rd Tuesday, November 16, 2010

    AFAIK, phpdoc still has no support for 5.3 (namespaces) and is as such pretty much useless. Including support for phpdoctor (https://github.com/romanb/phpdoctor) might have been a better option.


  • Ryan Tuesday, November 23, 2010

    The above comments show this working using xampp, is it possible to run NB on my local machine with phpdoc setup on my \*nix server and specify the PhpDoc script location on that server?


  • Bruno De Barros Wednesday, December 8, 2010

    For those of you getting the following error:

    Parsing configuration file phpDocumentor.ini...

    (found in .\\pear\\data/PhpDocumentor/)...

    ERROR: cannot open phpDocumentor.ini in directory C:/xampp/php/PEAR/PhpDocumentor

    -Is phpdoc in either the path or include_path in your php.ini file?

    If you can call phpdoc from the command line and it works, but it doesn't work on Netbeans, the solution is simple:

    In the first line of the phpdoc.bat file, add:

    cd "C:/Users/your-username" (if you're on Windows 7/Vista)

    OR

    cd "C:/Documents and Settings/your-username" (if you're on Windows XP)

    Replace your-username by your username, obviously.

    The reason why it works when you call it from the command line is that when you open the command line, it opens in your home directory. That means that when you use php, "." is your home directory. When Netbeans uses php, "." is some other directory (not sure what it is now).


  • Dani Thursday, December 23, 2010

    My NetBeans hasn't PHPDoc tab at the Option->PHP windows. How could I enable this tab?


  • Bruno Monday, December 27, 2010

    @Dani, this option does not exist in Netbeans 6.9.X. It'll only be available in Netbeans 6.10 (now to be Netbeans 7). Try reading the comments the next time.


  • marqusG Wednesday, January 5, 2011

    Hi. I'm running Netbeans 7.0 beta on Windows 7 with php 5.2.14 installed in G:\\PHP and PhpDocumentor 1.4.3 installed in G:\\Apache\\htdocs\\. I added this last directory (G:\\Apache\\htdocs\\PhpDocumentor) to include_path in php.ini and restarted server. Within Netbeans I have set: G:\\Apache\\htdocs\\PhpDocumentor\\phpdoc.bat -o HTML:frames:DOM/default.

    But when I try to create documentation I receive this error "Could not open file: phpdoc".

    Both file (phpdoc.bat and phpdoc are present in G:\\Apache\\htdocs\\PhpDocumentor. Googling didn't solve this problem. Have you any idea? Thanks


  • Jeffrey Rubinoff Thursday, January 20, 2011

    I'm working on a screencast demonstrating phpDocumentor support. Can someone tell me if the phpDocumentor.ini problem that Bruno solved is unique to Windows, or can it happen on other OS?


  • Jeffrey Rubinoff Tuesday, January 25, 2011

    Interesting. On an XP box, when I ran the Pear installer from C:/xampp/php, phpDocumentor.ini was generated not in my user dir but in C:/xampp/php/pear/data/PhpDocumentor.

    When I uninstalled and reinstalled using Pear but running it from C:/Documents and Settings/nbuser, phpDocumentor.ini was generated in C:/Documents and Settings/nbuser/pear/data/PhpDocumentor, as I originally expected!


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.