An Oracle blog about NetBeans for PHP

Adding a ShortCut for Generation PHP Documentation

This is a tip how to add a shortcut for generating PHP Doc for  a class or method / function. Probably every body who uses PHP editor in NetBeans knows that if you write start of PHP Documentation /** just before a class or method/function and hit ENTER, then NetBeans tries to finished the PHP Documentation and adds PHP Doc tag, if there are needed.

This feature is not implemented as an action, it's based on the code that checks what is written on the line after pressing ENTER key. And because it's not an action, it's not possible to assign shortcut for it. If you want to use a shortcut, you can use editor macros. An editor macro is sequence of pressed keys and actions in the source editor and you can assign a shortcut to the macro.

By default the editor toolbar contains buttons for recording macros.

Start the recording of new macro through pressing Start Macro Recording button. Press type in editor /**, press ENTER key and then stop the recording through Stop Macro Recording button.

In the New Macro Dialog place name of the macro. I have called it PHP Doc.

Through the Set Shortcut ... button assign a short cut. In my case I have used ALT+D combination. You don't have to write it in the Shortcut text field, it's enough to press the combination of keys. Close the dialog and you are done.

Now if you have cursor just before a class or method or function and press ALT+D shortcut the PHP Doc is generated. Like in the picture below.

If you want to change the shortcut, edit or delete a macro, you have to go to the Tools->Options dialog, Editor category and choose Macros tab.

The macros are more powerful, but this is a small example how can use it. Hope that it will be helpful for someone.

Join the discussion

Comments ( 2 )
  • kamil Thursday, June 2, 2011
    About Generation PHP Documentation - you could also add a shortcut in Navigator by pressing right click and choose generate documentation, it could be useful - Many users are was searching this feature in this panel,
  • Raymond Sunday, August 7, 2011

    How about adding in support for PHP 5.4 built-in web server?

    See it here:


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