2012-06-18

Ruby and legacy applications

This post isn't about JRuby + Rails + Spring (or other Java web frameworks) like my first intuition would tell to me.

I'm currently helping my friend to renew her website and I was looking looking for pow-like application for PHP, because didn't want full apache on my laptop. I googled and found way to run PHP website in pow. This operation is possible with rack-legacy gem.

rack-legacy provides middleware where you can run legacy php and cgi in rack stack. gem is in alpha state and in production you should use apache or some other server software for performance. For my local development environment this suited perfectly.

What did I want to do then. Well I wanted to have PHP powered website running on my local environment without too much configuration. I also wanted quick way to show currently working site to my friend and she isn't a technical person so git cloning wasn't the answer. So I wrote this config.ru-file, which runs index.php with correct parameters in every request. Symbol link under the .pow dir and I got undulaatit.dev site visible on my laptop. I have used localtunnel before so it was first choice this time too. rackup and localtunnel 9292 ftw. I pasted localtunnel url to my friend and she could see my changes in real time.

I think I find this approach useful in future too. I have done lots of stuff in PHP before moved to Ruby and some of the stuff I have planned to port in Ruby as well. Now I can do the migrations in little parts. At first using rack-rewrite to direct all request to PHP. Then I take one page, write it in Ruby and don't redirect it to PHP. Now the functionality stays same all the time, but the implementation changes under the hood.

Feel free to leave a comment about this kind of approach to rewrite legacy applications in Ruby.

PS. rack-rewrite is heroku friendly http://icelab.com.au/articles/useful-heroku-friendly-rewrites-with-rack-rewrite/

No comments:

Post a Comment