Thursday, August 07, 2008

Real-world experience with the new NetBeans PHP and JavaScript editors

One of the challenges for someone who builds products but doesn't necessarily use them is that you can get so busy with your day job that you don't know what it's like to use the product.

I do use NetBeans during my day job, writing Java code for the NetBeans product itself. So I am definitely getting my hands dirtier than when I was working on the app server or Java DB. But NetBeans is vast, and there are some areas that I just don't get enough exposure to, but which are directly relevant to my job.

In particular, a large chunk of database applications today are web applications written with PHP and JavaScript. I am quite aware of the new JavaScript and PHP editors, but had not had much experience with them.

Yesterday I spent the whole day trying to help a friend in need who had waded in too deep with a contract he has. He has no database experience, and was trying to customize a Wordpress plugin that uses PHP, JavaScript and MySQL.

So I downloaded the daily build of the PHP bundle of NetBeans for 6.5 and started working. I had done a previous PHP project using vi, and although I was fairly productive it was somewhat painful. So I was so happy to see so many of the things in the NetBeans Java editor available for JavaScript and PHP: completion, inline documentation, easy refactor/rename, goto declaration, find usages, error highlighting and so on.


I felt much more comfortable and productive in this environment. The PHP support even has FTP integration to make it easy to push to a remote site.

But I also spent a lot of time doing SQL in PHP, and had a number of ideas on how to make it easier to work with SQL in a code editor .

One thing is that for this project, as it is for many, MySQL is on a remote server on the Internet. Our entire Database Explorer is useless in such a scenario, as it requires a JDBC driver connecting to a server available on the LAN.

SSH Tunnel Support

There are HTTP JDBC proxy drivers, but what most people usually do is set up a ssh tunnel using a tool like PuTTY for Windows or OpenSSH for UNIX systems. Wade Chandler provided useful instructions for how to do this with PuTTY. Here is another good page on how to do this.

But I can imagine finding a way to make it very easy to configure a Database Explorer connection to use an ssh tunnel. This simple thing could be a big win for a lot of our users. I'm not sure what platform-specific dependencies there are and if this is possible in a Java environment, but I'm going to check it out.


Add Column Wizard

I have been thinking about how to do SQL completion in the PHP editor for a while. But during my work yesterday another itch came up that I would like to scratch. As I worked on the code, I needed to add a column. It would be great to be able to add the column right there in the PHP editor - some kind of right-click or keystroke to add the column that I have highlighted in my text editor, and a quick dialog comes up to get the details of the column.


Insert DDL Wizard

The Wordpress plugin I was working with does something I have heard a lot of people do: right there in the PHP code, detect if the tables exist and then create the tables (or alter the tables if you are doing an upgrade).

This is different from what I'm used to - I had always created the SQL scripts as separate files - but when you think about the web deployment model, it makes sense.

So, a nice feature would be to provide an Insert Code wizard to generate all the CREATE TABLE statements in your code editor. Generating the ALTER TABLE statements is trickier, but hey, let's set our goals high :)

What do you think? What else could we do to make it easier to work with databases in your language editor?

1 comment:

Unknown said...

+1 on support for connecting to a MySQL db on a remote host. Lost count the number of times I've had to either ssh in or use phpMyAdmin to make edits.