Wednesday, June 11, 2008

Ya down with PHP? Yeah you know me!

So my company also operates another related site that required a little love. It's written in php. We had to make some changes to make a client happy. I volunteered, as I thought it might be nice to learn php. After some initial trepidation, I dove in and got the application running. Getting the LAMP stack running on Mac is kind of annoying - minor weirdness with different packages and odd compatibility issues - that kind of crap doesn't exist on linux - in Ubuntu the work is accomplished by doing this:

sudo apt-get install apache2 php5-mysql libapache-2-mod-php5 mysql-server

And BAM! It works. How easy is that! Man I love Ubuntu. I should get a t-shirt that says that or something.

ANYWAY, back to the point of the post - I had a hard time getting the LAMP stack running, but I finally got it going. I got the application I needed to work with up and running in no time once the servers were setup, but we hit a snag. Some of the work I am doing requires SSL. SSL is a pain in the ass. I could not, for the life of me get it setup. Missing .so files in mac, weirdness once I found them, compilation errors, how many times must I run make and make install? This sucked, until I found this awesome MAMP program, that bundles php5, apache2, and mysql into one Mac application. This had some promise. It installed just like a regular app, and provided a GUI interface for the most common apache setup stuff, like document root. Did I mention IT'S FREE. Who are these awesome nerds that do these incredible things for us? Once I discovered this awesome tool, I was able to follow simple directions on how to setup SSL, create a bogus self-signed certificate, and holy crap, it just worked!

Since then, I have been diving right into the craziness that is php. Little intricacies like php pages that have html forms that submit back to the same php! Odd. Symbols like -> and => where there should be dots. Some things are similar. Braces. Semicolons at line endings. All in all, I found php to be a pretty simple language. I can't say I understand it fully or anything, but I am certainly able to poke around this application and make things work. I LOVE arrays that are really just like maps, or can be just like arrays. I love the convenience methods like print_r to print out all the contents of an array. Now as someone who has done almost all my programming in java, and especially in java web applications, here's the kicker. I would make a change, then refresh the page, and the change was already there. Yep. Pretty awesome. No build.xml that then deploys to the server that you then restart, then re-login to your application to see what the change did. No sir. So my lack of php skill didn't put too much of a dent in productivity. That's awesome.

I am now truly excited to rock out with Groovy or Scala or one of these other JVM-based scripting languages, so that I can get the best of both worlds. Things are going to get interesting! Man I am a horrendous nerd.