How to setup Netbeans Project for WordPress Plugin/Widget Development

I am wanting to locally develop a suite of WordPress plugins and widgets. My development environment consists of Windows v8.1, Netbeans v8.0.2 and XAMPP v5.6.3.

I’ve configured Netbeans and PHP to use XDebug. I’ve spent the entire weekend watching and reading various tutorials on setting up Netbeans IDE for developing a WordPress plugins/widgets.

Read More

Everything seems to be working at this point – I’ve been able to create new Netbeans projects by opening existing/installed plugins of my WordPress install. I am able to set breakpoints and trace through code. All seems to be working well, but I am puzzled regarding the ‘proper’ way to setup a new project.

Should a plugin/widget project somehow include the WordPress core files starting at .htdocs, or should the root of the project be .htdocswp-contentpluginsmyplugin? In other words, should I be able to see .wp-admin and .wp-includes in my project tree?

My thinking is that Netbeans needs to somehow be able to read the core WordPress files to provide function reference during development of the plugin/widget and this would require including the WordPress core in my project, somehow.

Maybe my question is best asked this way:

What should the root project folder be set to for developing/debugging a plugin named MyPlugin?

and/or:

How are WordPress core files included/referenced in the MyPlugin project?

Anyone have a good step-by-step reference that would enlighten me on this?

Related posts

Leave a Reply

2 comments

  1. I’m searching for this too, but here’s how I set it up. I’m developing a theme (plugin would be analogous) so I have the theme source and NetBeans project files in a separate folder outside of WordPress folder, and outside of the xampp/htdocs actually. Then, I set the root of my PHP project to this theme source folder, and then using the Project Properties -> Include Path facility to allow NetBeans to include the WordPress folder, it will appear under Include Path in Project Explorer, enabling ‘IntelliSense’ etc. This way you can start a new NetBeans project per plugin/theme, basically, just including the WordPress core in each. Furthermore, I have NetBeans set up to copy the source files to the xampphtdocsmysite2wp-contentthemes folder on save and project load (set up in preferences). Here’s a pic: NetBeans WordPress Setup

  2. The best way I’ve found so far is to use a hardlink.

    If I keep the files in Netbeans’ project directory everything works. But WordPress sometimes does not recognize that the theme is there. I.e. in some wp-admin menu’s. But I’m able to display a Theme just fine.

    1. I create the project as a php project in Netbeans.
    2. Then link my (pubic html) folder from the Netbeans directory.

      mklink /J C:LinkToFolder C:UsersNameOriginalFolder
      

      Use ” quotes if your path has spaces

    I use:

    mklink /J "C:xampphtdocswpthemewp-contentthemesthemename" 
    "C:UsersProbook 1DocumentsNetBeansProjectsprojectnamepublic_html"
    
    1. Then I setup the netbeans project to load an external page when I run the project. (See File => Project Properties=>Run Configuration)

    I’ll be looking into doing the same with plugins soon. Practically I can’t see a reason this won’t work for plugins too.

    I want to try and see if Netbeans copes with the hardlink better than Apache does. (I.e. if I setup the project first then move the files to Xampp and create a hardlink in Netbeans’ project directory. I.e. Projectnamepublic_html
    (If anyone does it first let me know how it goes)

    It’s more important to me that Netbeans can backup and function. As long as I can display what I’m developing realtime.

    AFAIK Netbeans can intergrate with Xampp to run it’s debugging (Xdebug)