WordPress and NetBeans

Here’s a few tips for how to make the most out of NetBeans for developing WordPress websites.

Making NetBeans aware of WordPress functions so it can suggest autocompletion

Working with WordPress, I often have to look up how to use a function I’ve used before, but have forgotten the order of parameters. The codex, and in particular the WordPress function reference and WordPress template tags reference pages are great places to look for such things. However, if you set up NetBeans to be aware of the WordPress functions, sometimes you can save yourself a trip to the codex. NetBeans is by default aware of any functions defined within any files in your PHP include path, as well as any functions you have defined in your project. One way to make NetBeans aware of the WordPress functions would be to have WordPress core within your project, but I would prefer to not have it there. When working on files on remote servers, main reason I would use NetBeans over vim, it is a little bit cumbersome to download all of WordPress core, and I usually only download what I need from wp-content. In such a scenario, you can teach NetBeans to also load a local copy of WordPress into memory. To teach it that, go to Tools -> Options, then PHP tab.

Code completion will then be enabled, and the PHPDocs in WordPress will be parsed shown when looking at the available functions. In the picture below, I typed ‘WP_Q’ and the autocomplete functions became available below it, as well as the documentation dialog above it.

WordPress Coding Style Adherence

The WordPress coding standard defines how your code should look so that it looks the same as the code in WordPress core. Adhering to a coding standard is a good idea because it promotes consistency and makes for easier reading of the code you write. I’ve prepared an export of the Netbeans configuration for the editor to adhere to the WordPress coding standard. I hope you find it useful! To import it, Click Tools -> Options in the top menu, then press the “Import” button in the dialog window that comes up and follow the instructions there.

What’s Next?

A nice feature that is not available to the extent of my knowledge would be templates for common WordPress files, like there are template for Java classes, and such. The way this would work is you could say “I’m going to make a new theme” and it would create all the files a theme requires. Or “I’d like to make a widget.”, “I’d like to write a shortcode.” and NetBeans would create the “boilerplate” code so you can get to coding right away.

Do you have any NetBeans tips you’d like to share with your fellow WordPress site builders? Do you know of a plugin for NetBeans that adds those templates I mention in the section above? Thanks for reading.

Published by

Dan Bernardic

A Winnipeg Web programmer. Proud member of the Skip the Dishes team. Experienced with Web technologies, e.g. HTML5, CSS, ( Server-side ) JS, PHP, WordPress, MVC, etc.

8 thoughts on “WordPress and NetBeans”

    1. Hi Tomas,

      Thank you for the question and comment!

      A dirty little secret is that I never use NetBeans any more. I am not sure whether it is still valid for new versions. Please let me know if you try it.

      Yeah, my website’s uptime is not great. I had mysql issues this morning :-/

      1. Hey Dan,

        you say you dont use NetBeans any more.
        What do you use instead to develop Worpress Themes?

      2. I don’t develop WordPress themes much these days.

        My preferred text editor is command-line Vim. I use Atom when I need a GUI.

        A very common choice among my peers these days is Sublime Text.

        Hope that helps. Thanks for asking.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s