If you have issues with netbeans and xdebug not connecting on recent distros, you might find that netbeans is listening on tcp6 and xdebug connecting on plain tcp.
To check if this is the case, run the following command whilst netbeans is “waiting for connection” (change 9000 if you’ve set a different port) :-
netstat -aln | grep 9000
if you get a line similar to the following (specifically tcp6 and not just tcp), it may well be that xdebug can’t connect over ipv6 :-
tcp6 0 0 :::9000 :::* LISTEN
One solution is to disable ipv6, which can be done by creating the file /etc/sysctl.d/10-disable-ipv6.conf with the following contents :-
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
then run (as root or sudo)
sysctl -p /etc/sysctl.d/10-disable-ipv6.conf
and restart netbeans. Suddenly, netbeans will listen on tcp (ipv4) and xdebug will connect.
netbeans, By:
admin
4 Comments
Tags:
developer,
development,
ipv6,
linux,
mint,
netbeans,
php,
solution,
ubuntu,
xdebug
If you are using a Java application on your nice new Linux Mint desktop and are wondering why its so damn ugly, this might be your solution.
It looks like there is an issue with Java detecting your standard system style, fonts etc so it reverts to something pretty hideous.
One easy solution to at least get it looking alright (and also fixing a bug with menus and maximisation) is to set your netbeans conf to the following.
Simply go to your netbeans folder and look for an etc folder.
Inside there is a file called netbeans.conf
Back that up (rename to netbeans.conf.backup) and create a new file called netbeans.conf
Then paste this in:
# ${HOME} will be replaced by JVM user.home system property
netbeans_default_userdir="${HOME}/.netbeans/7.1.2"
# Options used by NetBeans launcher by default, can be overridden by explicit
# command line switches:
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true"
#trying to fix teh UGLY
netbeans_default_options="${netbeans_default_options} --laf Nimbus -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd"
# Note that default -Xmx and -XX:MaxPermSize are selected for you automatically.
# You can find these values in var/log/messages.log file in your userdir.
# The automatically selected value can be overridden by specifying -J-Xmx or
# -J-XX:MaxPermSize= here or on the command line.
# If you specify the heap size (-Xmx) explicitly, you may also want to enable
# Concurrent Mark & Sweep garbage collector. In such case add the following
# options to the netbeans_default_options:
# -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled
# (see http://wiki.netbeans.org/FaqGCPauses)
# Default location of JDK, can be overridden by using --jdkhome <dir>:
netbeans_jdkhome="/opt/java/64/jre1.7.0_04"
# Additional module clusters, using ${path.separator} (';' on Windows or ':' on Unix):
#netbeans_extraclusters="/absolute/path/to/cluster1:/absolute/path/to/cluster2"
# If you have some problems with detect of proxy settings, you may want to enable
# detect the proxy settings provided by JDK5 or higher.
# In such case add -J-Djava.net.useSystemProxies=true to the netbeans_default_options.
netbeans, By:
admin
2 Comments
Tags:
13,
border,
bug,
java,
linux,
mate,
menu,
mint,
navigation,
netbeans,
problem,
solution,
ugly,
window
So, this is documented in the manual, but isn’t obvious in any menu :-
To uppercase a selection, press Control+U then U.
To lowercase a selection, press Control+U then L.
and to reverse case in the selection (for when you have typed a whole line of code without checking your caps lock!), press Control+U then S.
Really useful but not well known.
March 8, 2012
No Comments
One of the features that I was previously unaware of in Netbeans is its ability to automatically generate common class methods. This post is a quick guide of how this works for future reference.
To get the system to work, first load up a php class. For this example I’m going to be extending the Magento Product Model. This basic class can be seen here, with a couple of extra properties added.

To start generating the methods you need to press [Alt] & [Insert] and you will be presented with a menu similar to the one below

This lists all of the common methods that do not currently exist within the class. The first thing that we’ll do is to generate a constructor, which gives us the following options

Here you can select which of the class properties you want to be set using the constructor. Pick the ones you want and click OK, and the following code is generated

The Getters and Setters work in the same way, and the Override & Implement provides you with a list of all of the methods that the class can override from its parents. Using these together can help you to quickly all of the methods you need in minutes, as shown below.

February 7, 2012
No Comments
If you have a dual monitor setup you might decide to undock some of your Netbeans windows, for example for running XDebug sessions or PHPUnit testing.
However you will find that by default, Netbeans sets the transparency of these windows to unreadable levels when they are not active.
This really defeats the object and is quite irritating.
I spent a long time under the false impression that this was some errant compiz setting and trying to figure it out that way.
Turns out that this is a Netbeans “feature” and you can disable it with a single untick of a box.
Tools-Options-Miscellaneous-Appearance
untick the “Transparent floating windows” box
Enjoy lots of usable desk space in Netbeans!
netbeans, By:
admin
No Comments
Tags:
dock,
docked,
linux,
magento,
netbeans,
opacity,
popup,
transparency,
transparent,
window
January 19, 2012
No Comments
If you use Netbeans then you have no doubt seen the red wavy underline that pops under lines that have errors.
Unfortunatley if your errors relate to punctuation, eg concatenation full stops, then the red wavy line can actually obscure these making finding and fixing the error tricky.
An nice alternative is to set Netbeans to use a red strikethrough instead of the wavy line. This is just as visilble but does not obscure punctuation in any way making finding and fixing the error a lot easier.
To change this simply go to Tools-Options-Fonts & Colors
Then Set Language to All Languages
Then select Error in the category drop down
Simply change the Effects: drop down from Wave Underlined line to Strike Through
January 10, 2012
1 Comment
When using PHPUnit with xampp the first the to do is install PHPUnit through pear. You usually need to update pear first, after that you should be able to follow the instructions here
Getting PHPUnit working with Magento is fairly straight forward. It’s just a case of including Mage.php and then calling Mage::app(); in the setup method of your test class:
<?php
require_once '../app/Mage.php';
class TemplateTest extends PHPUnit_Framework_TestCase {
public function setUp() {
Mage::app();
}
public function testExample() {
$helper = Mage::helper('core');
$this->assertTrue($helper instanceof Mage_Core_Helper_Data, "Magento isn't running!");
}
}
If you use NetBeans as your IDE you’ll be glad to know that it has support for running your tests directly without having to use a terminal. This does require a bit of configuration. You need to tell NetBeans where the PHPUnit script is under Tools Options PHP Unit Testing. If you are using it with XAMPP it will be located at /opt/lampp/bin/phpunit. To begin running the tests you then go Run Test Project and NetBeans will ask you where your tests are. After that you will get a “Test File” source folder in the Projects pane. You can now right click each test file and choose “Run file” and netbeans will run it. If you have xdebug setup the debug option also works nicely.
There is a new feature in Netbeans that tries to auto fill the variables for methods and functions in PHP. Whilst this may be something that is a time saver for some, it often gets these wrong, and if you are using descriptive variables in the method then these are overwritten if you have a variable of the same type above your method call.
Thankfully there is a way to disable this feature and revert to the old ways. In netbeans go to Tools - Options - Editor - Code Completion and select Language PHP. From there you can deselect the Use Smart Parameters Pre-Filling and netbeans will work the way it used to
I recently installed the latest version of Netbeans (7.1) and decided to have a look through the available plugins at the same time. In there I found one called Quick File Chooser.
This replaces the file selector with a keyboard optimised version, which includes auto-complete and narrowing down a file list as you type.
If you prefer the keyboard over the mouse this is a required extension!
October 3, 2011
1 Comment
If you want to quickly comment out a block of code in netbeans you might find the following really useful
Simply highlight the block of code and then hit [ctrl]+[shift]+
The same key combination will uncomment it again.
Handy!