Ruby to PHP
I’ve been porting the BYUFHLC to PHP, and it’s coming along pretty well in spite of a number of mini-setbacks. The only tricky part was figuring out how to parse the HTML from the screenscrape. At first I was going to use Troy Wolf’s class_http, but it didn’t seem to have any functions for actually doing anything with the HTML once it was fetched. Then I discovered the new DOM stuff in PHP 5.
Excitedly coding up a few lines to test it, I ran into function-not-found errors. Ten minutes later, I realized that Bluehost’s servers were running PHP 4. (Side note: I’d tried to get PHP running locally on my Mac, but it wasn’t serving the PHP; instead it would just display them as plain text.) I called them up and they said it’d take a 24-hour downtime to migrate my domains over to the PHP 5 server. That was unacceptable.
So, I went hunting around in /etc/httpd/httpd.conf again, and I found a line reading “<IfModule mod_php4.c>”. Changed the ‘4′ to a ‘5′ and it all started working perfectly.
After that, it only took twenty or thirty minutes to convert my Ruby code to PHP, and I’ve got the first set of results working perfectly. But now my stomach is grumbling because I haven’t eaten in a long time, so finishing this up is going to have to wait till tomorrow. I’m glad it’s going to be a fairly easy port. (From here on out it’s smooth sailing, since I’ve worked out all the DOM issues.) Expect another status report tomorrow.
And no, I’m not converting to PHP. :) I love Ruby and will continue to use it whenever possible.

Technorati Tags:
Posted in 

