Cheap phentermine Orbitz Savings account payday loan Flomax Arizona auto insurance Vonage Debt consolidation company Full tilt poker Montelukast Furniture Phentermine 37.5 Smash repair Zovirax Tadalafil Football handicapping High stakes poker Foreclosure Sell real estate note Airline tickets Ephedrine Cholesterol Propecia online Occupational therapy Fioricet online Consolidate credit card Buy clomid Medical assistant Cheap hotels Cheapest tramadol Superbowl predictions Credit card debt relief 3 in 1 credit report What is adipex House Auto owner insurance Get viagra Allergy Paint Lorazepam Super bowl props Accutane Sildenafil citrate Buy paxil Casino portal Instant payday loan Cialis levitra Tamoxifen Super bowl pool Pharmacies Cheap carisoprodol Tramadol ultram Porn Get out of debt Clarithromycin Buy generic viagra Online payday loan Virus and spyware protection Cardiology Car insurance quote Build 

WordPress development with NetBeans IDE 6.5 for PHP

datePosted on 02:47, November 22nd, 2008 by Millan

For the last few months I have been following progress on the development of new NetBeans with PHP support. And, few days ago final NetBeans IDE 6.5 for PHP has been released.

From NetBeans official website you can choose download you need. You can download PHP only NetBeans (24MB) or you can choose full NetBeans (250MB) that includes editors for Java, PHP, Ruby, C/C++ with Apache Tomcat and GlassFish servers. You can choose Windows, Linux, Sparc or MacOS versions.

NetBeansIDE 6.5 Logo

If you are using Windows as I am, to run NetBeans you need any MS Windows XP (including x64 edition), MS Windows Vista or any MS Windows Server. You also need latest Java RunTime installed. I have tested NetBeans 6.5 with both 32bit and 64bit (with both 32bit and 64bit JRE) Windows XP, and it works without a problem.

I will describe the process of using NetBeans for developing for WordPress, and also some interesting features this IDE has to offer.

Importing WordPress

After you install NetBeans, you need to import complete WordPress installation. This installation contain. It’s best to import WordPress directly from your local development webserver. This way you can have fully functional WordPress instance configured on your localhost server.

This installation can be used to develop both plugin and themes.

Import Step 1: Creating Project

1: Creating Project

[caption id="attachment_454" align="alignleft" width="198" caption="2: WordPress Location"]Import Step 2: WordPress Location[/caption]
Import Step 3: Run COnfiguration

3: Run Configuration

Images above show all 3 steps for importing WordPress folder into NetBeans project. In step 2 you need to choose folder with WordPress installation from your local webserver root folder. Also, you need to set project name. Last option (I left it unchecked) is used to determine where NetBeans is going to save it’s metadata. I recommend leaving it in the project folder.

Step 3 is used to set server parameters. To be able to debug application, set it to run as local web server, add full URL that you would normally used to run project on your webserver. Last option is to make a copy of the source files into separate folder. This will cause that NetBeans makes a copy of all project files into designated folder, and every time you want to run it, it will be deployed back to webserver location. I don’t recommend using that, because it will slow down your development process.

Setting XDebug on your local webserver

NetBeans supports PHP debuging. For this you need XDebug set on your local webserver. This is very simple to set up, and maybe you already have that on your webserver. If you don’t, here is what you need to do to enable debug:

  1. Download XDebug from official website. You need to get DLL for your PHP version.
  2. Copy that DLL into extension folder (easier to track), or any other folder.
  3. Modify PHP.INI. You need to add few new lines. In the first line is the full path to xdebug DLL. Change this to the path on your machine. If your PHP.INI already have zend extension directive, you must remove it. Only one such line can exist in the PHP.INI. Also, last 3 lines are not required, but you will need them if you use 64bit Windows XP. Full list of settings for XDebug can be found on their website.
  4. [xdebug]
    zend_extension_ts="D:/wamp/bin/php/php5.2.6/ext/php_xdebug.dll"
    xdebug.remote_enable=On
    xdebug.remote_host="localhost"
    xdebug.remote_port=9000
    xdebug.remote_handler="dbgp"
  5. Restart webserver.

After you do all this, NetBeans will know to use debugger. You might wanna set few things in options (Tools->Options->PHP) like debugger stopping at first PHP line or adding more paths for include.

NetBeans IDE Environment

Full IDE has many options, and you will not going to have all the panels visible at the same time. As many other modern IDE’s, NetBeans support profiles with different panels placements. When you start debugger, IDE will reconfigure itself to show watch, locals and other debug related panels.

NetBeans IDE

NetBeans IDE

IDE has advanced inline auto complete and also shows help for PHP functions. I will not go into too many details about the NetBeans IDE features, you can find complete list and videos on NetBeans website.

Projects Panel

Projects Panel

Debugging WordPress plugin or theme

Once you import WordPress instance into NetBeans as a project, this project will appear in the projects panel. For each project you have Source Files folder and Include Path folder. As you can see, under source files for imported WordPress project you can see standard WordPress installation.

Best thing about this is that NetBeans will scan entire project, and will index all functions and classes in WordPress, will read all phpDocs, and all that will be available to you. So you can use WordPress functions as inline auto complete feature just like you use standard PHP functions and classes. If a WordPress function has phpDoc block, then NetBeans will show you that documentation and meaning of each parameter function expects.

Open wp-content folder, and in it you will find standard plugins and themes folders. Open plugins folder and select plugin you are currently developing. Right click on the folder containing your plugin, and in context menu that appears, in the Tools menu item select Add To Favorites. This will add your plugin to the Favorites panel, and you can access your plugin quickly.

Debug

Debug

Now you need to open any plugin file, place a breakpoint on the line where you want debugger to stop (Ctrl+F8). On the main toolbar you will find two buttons with green Play icons. First will run the website without the debugger.

The second one will run the whole project. When you run debugger for the first time, you will get a popup asking you if you want to use only PHP debugger, or both PHP and JavaScript debugger. If you choose only PHP debugger, it will be run in your default browser. If you want both PHP and JS, you can use Firefox or IE. With this you can place breakpoints in PHP and JS code. This is really a great feature, but on 64bit XP or Vista you can’t use PHP and JS debugger in the same time with Firefox, only PHP debugger will work. But, with IE both debuggers will work, after you install script component update. Hopefully Firefox problem will be solved with some of the updates soon.

Debugger Running

Debugger Running

Anyway, when the debugger starts, browser will start rendering webpage until it reaches breakpoint.

In debug mode, you will see new toolbar with additional options for moving through code. Picture on the left shows that toolbar, and shows with green background current line where debugger has stopped. You can see panel with list of superglobals like $_POST, $_GET, $_FILES and all the other, and their current values. Also, one panel shows all watches you have set (each variable can be added to watch list even during runtime).

If you debug classes, be careful to add class variables like $this->variable. Debugger will allow you to change values of variables (notice the button with 3 dots in value columns). In some cases this can cause debugger to crash (I have seen this only twice in the past 2 months), but this is most likely XDebug problem.

If you want to debug themes, procedure is the same as it is for the plugin.

Subversion Support

NetBeans has built in support for SVN. If you use SVN for your projects as I do, this feature will be very handy. In the project file list, folders with changes will have small blue bullet icon, changed files will be displayed blue, and new files green. Also, when you open any file, new lines will be outlined in green, changed in blue, and red arrow will appear in the code to show where you have delete lines. You can use standard SVN operation like commit, update, merge and many more.

To use SVN you first need to install SVN plugin. Open Tools->Plugins and find Subversion on the list. Check it, and click install button. Follow the instructions, and after plugin is installed, and NetBeans restarted, you will have full SVN support. You can also set interval for NetBeans to check for plugin updates.

NetBeans PHP Blog

Official blog on NetBeans website has video tutorials and many other great articles on using IDE for PHP development. This blog is regularly maintained and new articles are added almost every day.

There are many features in NetBeans that you can use for easier WordPress development, and if you use it on regular basis (like I do) you will discover them soon enough. I will try to describe some of them soon in another article. Until then, enjoy new NetBeans IDE.

VN:F [1.1.7_509]
Rating: 9.5/10 (11 votes cast)
  • StumbleUpon
  • TwitThis
  • Technorati
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Fleck
  • YahooMyWeb
  • Live
  • Sphinn
  • co.mments
  • LinkedIn
  • MySpace
  • E-mail this story to a friend!
  • Reddit
categoryPosted in Tutorials | printPrint
Related Posts:

One Response to “WordPress development with NetBeans IDE 6.5 for PHP”

  1. clod on April 13th, 2009 at 4:51 pm

    Hi.

    I highly reccomend to try free PHP IDECodelobster PHP Edition with special WordPress plug-in.

    Regards,
    Stas.

    VN:F [1.1.7_509]
    Rating: 5.0/5 (1 vote cast)

Leave a Reply

You must be logged in to post a comment.