IDE


29
Apr 10

Netbeans 6.9: My New Favourite Features

Netbeans 6.9 beta was recently released, here are some of the new features for the PHP editor that are pretty awesome.

The first one is recognizing overridden methods and classes. This feature is great because it allows for better auto completion, and lets you find things faster.

Not only does it recognize that I am extending the class, it recognizes that the function I am writing is overriding a function in the parent class, and provides hints as to what that function did (based on the comments that you *did* write right?).

After you hit enter (because you actually want to override that function, you get this (including a call to parent::functionName()):

There is a little green circular O icon beside your function because it is overriding a parent function (granted this would make more sense if I were using __construct rather than php4 syntax). Hovering over the O tells you which function you are overriding, and where it is. Clicking on that icon will take you to the actual declaration of that function:

You will notice that there is a different green O icon (a square one this time, with a small black arrow. Hovering over that will tell you that the function/class “Is Overridden”. Clicking on it will give you the locations that Netbeans found it to be overridden. Clicking on one of those will take you to the location that it is being overridden.

The second feature that is quite neat is the updated commit dialog.

The first thing you will notice (if you used previous versions of Netbeans) is that they added checkboxes beside the files, much more intuitive than the way it was before (a bunch of drop downs that you would miss if you didn’t know they were there).

You can also now right-click on the files you are committing and there is now an option to view the diff of the file you have selected. Selecting the Diff option will show you the familiar diff view:

The second tab (Textual) will let you create a patch file from your changes:

This new tab also shows up in the Diff view, and you can create patches from the diff between two files (not sure how useful that actually is when they are completely different files), or the changes you have made to a single file.

In addition to the old badges for modified files (blue icon on parent folders, blue text) and new files (blue icon on parent folders, green text), there is now an error badge (red icon on the file) which will show up when there are errors in a file.

There are lots of other new features including ini syntax colouring, more formatting options, go to css declaration, it will display the value of a constant you are using.

There are of course many other new features unrelated to what I do every day, you should go check it out for yourself.


17
Mar 10

Documenting PHP Code

I know we all hate documenting code, but it can really help out future you or me when we need to go back and fix something. Poorly documented code is the bane of anyone who will be taking on your code after you leave (or invite more people into) the project. One thing that can really help is documenting the variables that you can get via the __get and __set magic methods:

<?php
 
/**
 * @property bool $development_environment
 * @property string $base_url
 * @property string $index_file
 * @property string $allowed_uri_characters
 * @property string $char_encoding
 * @property string $default_location
 * @property string $helper_prefix
 * @property array $auto_load
 * @property string $auto_load['helpers']
 * @property array $db
 * @property string $db['name']
 * @property string $db['user']
 * @property string $db['password']
 * @property string $db['host']
 * @property string $db['type']
 * @property array $users
 * @property string $users['table']
 * @property string $users['encryption']
 * @property array $users['fields']
 * @property string $users['session_name']
 */
class config{
	/**
	 * Get a var from the config values
	 * @param string $var
	 */
	function __get($var) {
		if(isset($this->data[$var])) {
			return $this->data[$var];
		}
		throw new Exception($var . ' does not exist in '. __CLASS__);
	}
 
	/**
	 * Set a new/current config value
	 * @param string $var
	 * @param multiple $value
	 * @return  multiple
	 */
	function __set($var, $value) {
		return $this->data[$var] = $value;
	}
 
}

Adding the @property values to the top of the class lets you see at a quick glance what default properties that the class gives you. It can even help you in your ide when you are trying to figure out what you can actually get out of a class:

Remember, try not to piss off future you, they know where you live.


7
Apr 09

Why I use NetBeans

I am sure you know by now that IBM was set to aquire Sun Microsystems this week. This would have been bad seeing as most of their products directly compete/overlap with eachother. Fortunately they backed off at the last minute (or at least they did not offer enough money for them). While this might be a barganing tactic I surely hope that this is not the case. If they had bought them, it seems to me that it would have meant the death of many of the great Sun products.

NetBeans is one that would have been dead really quickly, sure it would have survived as a fork of the code (since Open Source projects never really die) but it would have been making much slower progress than it does now. This is because of Eclipse which is a good product in its own right… but as someone put it:

NetBeans is the Mac of the IDE world… it just works

If you want to use php in eclipse you have to work at setting it up, if you want to develop in php, download the php package, ruby? There is one  for that too. Since they are all professionally developed as part of the package there is no need to work to get it going no need to route aroud the net trying to find which plugins you need, which ones are still supported (which ones are supported well), which ones do not conflict with eachother… You want to use SVN? Which one do you use? Subclipse? Subversive? Does it work with your version of eclipse? Your repository? Will it corrupt it? Does it work with the latest version of subversion? Can it use the command line version if it doesn’t? (On a side note, subclipse probably works fine since it is supported by tigris).

So, if you have a choice at work, try it, if not, try it at home. It even has an eclipse project importer. You have nothing to lose, it is free after all.


13
Jan 09

Netbeans Subversion > Eclipse Subversion

For many reasons I prefer Netbeans to Eclipse for a lot of my programming. Since it has added in proper php support, which is more polished than Eclipse’s php extension, it has become my default IDE at work too. Another thing that is nice is that the subversion integration is very well done. One thing that is nice is that it knows that you are actually using subversion (the existance of .svn files is a good clue Eclipse…), and it will install the subversion client for you if you don’t have it installed so that you can actually use subversion. Fancy. The Plugins link is under Tools… not say… the Help menu, a much better place for it me thinks…

netbeans-annotationsOne of my favourite features is the Show Annotations for subversion… that way you can blame people for what they have done, or atleast see what changes they have made since you last looked at the file. In Eclipse it opens up 3 windows and just doesn’t seem very intuitive to me… but when you open it up in Netbeans, it meerly adds them to the left of the text, all of the lines changed for a specific commit have the name of the author is coloured blue and the comment (there is a comment right?) is shown at the bottom of the current tab.