Jul 30 2009

NetBeans – a PHP IDE for the VS crowd

Pavel Lutskovsky

I know I’m not the only PHP developer on the planet who despises Eclipse, refuses to pay for Zend and thus does most of their development in some text editor devoid of the basic conveniences of an IDE. At the same time, I’m not the only PHP developer who spends quite a bit of time in the .NET world being spoiled by VisualStudio and ReSharper’s conveniences.

I’m sure this makes me a Microsoft sellout on many levels, but I’m not ashamed to admit it. Visual Studio (despite its many flaws) is the best IDE I’ve ever used. No it is not perfect. Yes I curse at it daily (no different than the mechanic cursing a wrench he’s used for years). But I get my job done. I don’t have to jump through too many hoops to do it. I just need an average machine with Windows.  The combination of Visual Studio with ReSharper is what allows me to stop worrying about using software and focus on writing good clean code. Yet for my PHP work, I’ve been stuck to Notepad++ and vi for too long.

Since I paid quite a bit for VisualStudio, I’m not too interested in dropping a lot of money on another IDE, so for the purposes of this comparison, I looked at free products.  Until recently, my choices came down to decent but not user-friendly IDEs in the Aptana/Eclipse vein, half-baked free IDE versions of a paid product (Komodo) or a simple text editor.

For small things, Notepad++ and vi are still my go-to tools.  But for the big stuff, the glamor (or lack thereof) of being known as the guy who codes in Notepad++ is finally gone. Good riddance. Since picking up NetBeans 6.5 in RC mode I haven’t looked back. Bottom line: NetBeans gives me an IDE where I can focus on my code rather than on learning how to use some oddly designed beast (Eclipse).  Yet, being an IDE, I have the conveniences I’m used to from my .NET development.

Here are a few of my favorite things:

  1. Code completion – all IDEs have this, but NetBeans is better for someone used to VS.  Full documentation for standard functions and linked files is made available with a simple keyboard shortcut.  Aptana’s and Eclipse’s default code completion is laughable. Just listing the name of the function?
  2. File browsing - just like in ReSharper, hitting a simple keyboard shortcut (Ctrl-O) to browse by type (and it takes CamelCase, whoohoo!) makes moving around in a large project incredibly easy.  The completion also takes into account linked code (i.e. PEAR, CakePHP, CodeIgniter) types.  Ctrl-Shift-O lets me browse by filename.  No more hunting for files across library directories. Ctrl-Alt-Shift-O browses by method.
  3. Search usages – surprisingly, even the shortcut is the same as my ReSharpered VS installation, Alt-F7.  I get a list of every instance of the variables usage across the project.  No more grepping and checking context to see if it’s really a different variable by the same name.
  4. Code walking – Ever since my Delphi (Borland studio) days, I’ve found Ctrl-clicking a variable or type to go to declaration indispensible.  VS doesn’t do this by default, but thankfully the guys behind ReSharper thought of this.  To my surprise (or are they reading my mind?), the guys at NetBeans did too.  Clicking a function’s usage takes me straight to its declaration.  What could be simpler? Aptana, take note, when I accidentally click on “require_once”, don’t take me to the file that’s being included.
  5. Decent javascript and CSS support.  I don’t spend a lot of time on them since I mostly do backend work, but it’s nice to know code completion, documentation and even CSS preview are available.  These are not my strong suit and it’s nice that NetBeans gives me a crutch with them.

To be fair, NetBeans isn’t perfect.  The CamelCase support for type browsing, CakePHP support and the SVN plugins could be improved.  Still, it’s the best free tool I’ve seen.  It fits my needs, as a guy who spends at least 40 hours a week staring at Visual Studio and wondering why PHP IDE’s are so far behind.


Feb 7 2009

Goodbye osCommerce, hello Zen Cart

Pavel Lutskovsky

After several months battling osCommerce for a client of mine, I’ve thrown up my hands and embraced ZenCart.  The only pain in the process is knowing that had I done this sooner, I could’ve finished this project last month.  To compare the two is to compare a paraplegic to Michael Phelps.

OK… Maybe that’s a gross exaggeration.  I’m sure there are plenty osCommerce users in the world for whom it works well.  The problem is it didn’t work for me without having to debug payment modules.  Out of the box, the latest version was clunky, required register_globals to be on (deal-breaker), used a non-W3C compliant layout, had zero skin previews on its site and refused to work with PayPal Advanced Web Payments. This makes it a poor solution for my client — small business, no merchant account with a large bank, limited budget, limited time.  Something had to be done and after going through seven circles of hell with osC,  on a whim I tried Zen Cart.  I was hooked.  Not only did it work out of the box, but there was actual documentation, W3C compliance, much more flexibility, AND it worked with PayPal immediately.

So, if you’re stuck with an e-commerce package that requires you have register_globals set to on, doesn’t quite work with paypal and isn’t W3C compliant out of the box, this is for you.

It’s time to lose osCommerce and use a more modern solution.  The process is quite simple because Zen Cart’s schema is very similar in all key places to the osCommerce schema.  This is because ZenCart was branched from osCommerce a while ago. While the PHP changed, the schema remained very close to the original. The upgrade is simply a matter of installing ZenCart where you need it, running some DB scripts, and moving a few image files.  I went from osC 2.2 to Zen Cart 1.3.8.  I’m not sure if the below instructions will work for other versions, so you should check the schema before proceeding.

First, install ZenCart.  I put mine at /[site directory]/zen.  Create a DB for it and then just follow the instructions.  If you’re on DreamHost, there’s a one-click installer available.

Next, you’ll need to run some db scripts to move your data over.  If you don’t want to mess around with manually reviewing each table, a data compare tool is imperative.  If you have a Windows machine available, Toad for MySQL is a free tool which has a data compare function. There are alternatives that cost over $200.  You can also use phpMyAdmin to export the necessary data and import it into Zen Cart.  The bare minimum tables you’ll need are below.  When preparing this, note how many tables you selected. This will help debug the import if things go wrong.

address_book
banners
categories*
customers*
manufacturers*
orders*
products*

You may have other content in tables like newsletters, specials, etc.  As long as you understand the general idea of comparing the tables before moving data, you can move those too.  In phpMyAdmin, select your osC database and click on the “Export” tab at the top.  Select the tables you want and use the following options:

Select SQL radio button under tables selection
un-check "Structure"
check "Data"
    x Complete inserts
    x Extended inserts
check "Save as file"

Next, just click “Go”. You can save or open the file.  You should have a SQL script containing all your really important product and customer data to move into your Zen Cart database.  So, select your Zen Cart database in phpMyAdmin and click on the Import tab. It’s time to move data.

Click “Browse” and select the file you just downloaded. Make sure the format of import file is set to SQL and click Go. You’ll get a status message telling you how many queries were successfully executed.  The number should be equal to the number of tables you selected.

Next, it’s time to move your product images.  The images directory in osC is /[installation dir]/images.  This is the same in Zen Cart.  You can use FTP, command line, a file manager, whatever you want to do this.  I just ran “cp -i * [zencart images dir]“. The “-i” flag will make sure you get prompted if there’s a conflict.

That’s it! You’re done.  Configure your store and start selling.