Categories
Web Development

Web Frameworks or: How I learned to stop worrying about PHP and love Ruby

Right now I’m in the early stages of my first big project after launching the redesigned EduTech website. It’s an overhaul/redesign of a web-based application I wrote about a year ago to manage all of the workshops our trainers offer to North Dakota teachers. While my first stab at it was, by all accounts, a smashing success, we’ve learned some things in the last year that don’t jive with how the program currently works. Part of it is that our needs are changing as more and more workshops are taught, but I’m also not afraid to admit that I made some assumptions while building it that turned out to be off the mark. For example, I assumed one trainer, one date, and one location per workshop. Once our staff started offering classes via videoconferencing that also spanned multiple days, that model of mine broke down rather quickly.

In addition to fixing how our data is represented in our database, I’m also going to be adding some new features that should drastically improve the way we manage graduate credit for our workshop participants. All of that info is being kept track of in an Access database right now, which works, but isn’t the most efficient way of doing it.

I’m also using this rewrite as an opportunity to clean up my application code. Looking back, a lot of what I wrote is pretty messy. You probably wouldn’t know it by using the program, but it really shows whenever I need to go in and add a small feature or fix a bug. I’ve got no doubt that a big percentage of it stems from the fact that this was my first big PHP program, so I was learning as I went along. But, I used a bunch of different 3rd party PHP libraries (Smarty, ADOdb, HTML_QuickForm, PEAR Calendar, PHPMailer, FeedCreator, and JPGraph) that saved me development time in exchange for some pretty ugly code gymnastics.

The one thing that would have the biggest impact on my program rewrite would be to move it to a well structured web application framework. This would automatically force me to be consistent in my coding while giving me a foundation to build on. I’ve been doing research on some different PHP options, but have hit some pretty big roadblocks:

  1. Most of the web frameworks being created for PHP require that PHP 5 be installed on the server, something we haven’t done yet. This one isn’t a huge deal, but it means that I can’t test them right now.
  2. It appears that almost all of these frameworks are pretty early along with really crappy documentation and incomplete features. More than that, there are so many PHP frameworks that I don’t see a single one emerging as the community’s favorite anytime soon, if ever.
  3. These frameworks have no support for the Oracle database, or so little support that it might as well not be there.

To me, the most promising long term prospect is the Zend PHP Framework, but at this point it’s purely vaporware. So far it’s just been announcements and nice promises – not a single line of code has been made available to the public. The other PHP framework that looks alright is CakePHP, but it’s inconsistent documentation and weak support for Oracle make me nervous.

In the end, most of these new PHP frameworks are very lame copycats of Ruby on Rails. Some don’t even bother hiding that fact: PHP on TRAX anyone? The problem is, recreating Rails in PHP is very hard, if not impossible, due to the limitations of the language itself. Beautiful code written in Ruby quickly becomes ugly when it’s recreated in PHP. There are so many hacks involved that it’s not a pretty sight. Plus, why deal with a second rate knock off if you can use the real deal with just a little more effort?

I brought up the idea of switching to Ruby to our server team a few weeks ago, and I’m happy to say that it’s being considered. There are some issues that need to be considered, mainly ones related to deploying Rails applications on Apache. Other people are in the middle of solving these problems though, so they’re not show-stoppers.

In the end, it really comes down to a trade off between development time and server administration time. We’ll need to figure out if the time I save rewriting the program in Ruby on Rails is greater than the extra time and effort it’ll take to install, configure, and maintain Ruby on our web server.

I have to say – once you’ve written sometime in Rails, it really spoils you. I hate the thought of writing anything even remotely complex in PHP now that I know it can be done so quickly and easily in Ruby. Do you think it’s weird that every time I program in PHP, I feel so dirty that I want to take a shower?