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.

Comments:

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,

Posted by kamil on June 03, 2011 at 01:35 AM CEST #

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

See it here:
http://php.net/manual/en/features.commandline.webserver.php

Posted by Raymond on August 08, 2011 at 12:13 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

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

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today