In addition to its speed and refactoring capabilities, it offers the following:
- Formats your code according to Drupal Coding Standards
- It recognizes Drupal specific file extensions (.info, .module .install etc.)
- Replaces tabs with spaces
- Stores line breaks in UNIX format
- Character encoding of files can be UTF-8 by default
- Provides autocompletion with hint support for functions and classes project-wide, including Drupal core (provided core is in your project directory
- Code templates available for Drupal hooks
- Supports GIT, SVN and Mecurial version control systems out of the box
Note: These directions have been mostly updated to correspond to the current version of Netbeans (7.1.1 at this time). Most images are still from Netbeans 6.9 and were not changed if the setup was not significantly different. (LoMo — March 8, 2012)
Note: Windows users see http://drupal.org/node/1846954 to set up Netbeans, Xdebug, Drupal Dev Tools and Templates with Windows 7/XP and Acquia Dev Desktop (c11a - 11/21/2012)
Download the latest stable version of NetBeans, either the PHP bundle or the bundle labeled “All” (support for Java SE/EE and C/C++ as well). The page will offer the right version for you based on your browser’s operating system, but you can also select other platforms from the top-right drop-down menu.
After downloading, follow the instructions given by the installer. When the installation is complete, locate the Tools > Plugins menu item, choose the Installed tab, and activate the PHP plugin, if not already active.
Setting up Drupal Coding Standards
After you have activated the PHP plugin, go to Preferences (or Tools > Options) > Editor > Formatting, choose PHP in the “Language” drop-down, and choose Tabs And Indents from the “Category” drop-down. You should uncheck the "Use All Language Settings" checkbox in order to continue. After that use the following settings:
- Expand tabs to spaces: (check)
- Number of Spaces per indent: 2
- Tab size: 2
- Right margin: 80
- Initial Indentation: 0
- Continuation Indentation: 4 (if a new row is started within a condition)
- Array Declaration Indentation: 2
After that, choose Alignment from the category drop-down, and set "else and elseif" and "catch" to start in a new row:
Choose Braces from category drop-down and set everything to "Same line":
Choose Blank Lines from category drop-down and set 1-1 blank lines to be used before and after functions:
The last category is "Spaces". You should use the following settings here:
- Before keywords
- Check while, else, catch
- Before parentheses
- Uncheck Method / Function Declaration, Method / Function Call, Array Declaration
- Check if, for, while, catch, switch
- Around operators
- Uncheck Unary and Object operators
- Check Binary, Ternary, String concatenation, Key => Value and Assignment operators
- Check all options in "Before Left Braces"
- Uncheck all options in "Within parentheses"
- Uncheck “Before Comma” and “Before Semicolon”; check all others
When you have finished these steps, the code formatting will be just as required by the Drupal Coding Standards.
Setting up Drupal-specific file extensions and Drupal core functions
Go to Preferences (or Tools > Options) > Miscellaneous > Files, and click New on the Files tab. Add the following extensions one by one while associating the appropriate file type (MIME):
Associated file type (MIME) type should be text/x-php5 (for PHP files).
Finally, add the "info" and "po" extensions with MIME type: text/plain.
Now NetBeans will recognize these filetypes. The next step is to allow it to autocomplete Drupal core functions. For this to happen you need to download Drupal and extract the files to a folder (you don’t need to install it, you just need the files, so that NetBeans can read the functions), go to Preferences (or Tools > Options) > PHP > General, and add the folder to the Global include path list.
If you are also developing Drush-compatible modules, you should add the Drush folder to this list, to be able to use Drush functions.
Setting up Drupal hook templates
You just need to download the nb_templates from: http://drupal.org/node/1227436
- Win7 - unzip to C:\Users\\documents\
- WinXP - unzip to C:\Documents and Settings\\My Documents
- Linux users if you download the tar.gz file it will still include a .zip file once it has been extracted.
The unzip will place the files in a directory call nb_templates. Inside that directory find nb_templates.zip.txt and rename to nb_templates.zip.
Installation to NetBeans instructions are included in the README.txt.
- Rename nb_templates.zip.txt to nb_templates.zip
- Go to NetBeans > Preferences > Editor > Code Templates > Import
- Browse nb_templates.zip
- Select Editor > Code Templates
- Press OK
Please note that the import process will require a Netbeans IDE restart.
Using GIT version control system
Git-Support in Netbeans is included since Version 7.x (no additional plugin needed).
When there is no Git repository in a Netbeans project you use can make a "git init" via Menu "Team" > "Git" > "Initialize Repository ...".
In the Project Browser Netbeans is showing metadata at Project name and marks file status inside the repository like "modified". A Git-context menu is providing commands to work with the repository. So you don't have to leave Netbeans to commit code.
After you have set up localhost, and installed your Drupal, create a new PHP project with File > New Project, PHP, PHP Application with Existing Sources.
After clicking “Next”, you can set your project’s properties. I suggest using the sites folder of your installed Drupal as Sources folder. Select 5.3 for PHP version and UTF-8 for encoding. You don’t need to store Netbeans metadata in a separate directory.
Now you can click “Finish”, and you will see your newly-created project. After creating a new file, you can use the autocomplete, and you are ready to use your NetBeans for Drupal development.
Helpful Tools (Plugins and Helpers)
Visit https://www.drupal.org/node/1764074 for an overview of a simple to install and use Netbeans 8.2+ plugin that helps automate some of the above including new module files templates.
The Hungarian version of this page at here