Main Content

Presentation, Business and Persistence layers in Perl and PHP

Archive - Originally posted on "The Horse's Mouth" - 2006-04-17 21:21:58 - Graham Ellis

I've been writing about the Presentation, Business and Persistence tiers (and within each of them the MVC or Model, View, Controller or MVC structure) for a JBoss presentation I'm doing this week - but I scarcely expected to find myself putting them to good if unusual use this evening when sorting out an old page on our web site which had - err - laid neglected in a Perl script since before the last site update. How to fix this without re-writing what's actually a very nice piece of Perl ...

I've designated the Perl to be the business layer, and I've added an "Internal" interface type to it as well as the "post" and "get" interface.

In my new-look PHP page, I call up the Perl script through that internal interface passing in parameters as appropriate from the PHP using a shell_exec call. The internal interface returns a result set which I can then integrate in my presentation layer.

Neat - and what could have been a major rewrite was done in an hour. I've always said that the Java principles are great for the larger applications / sites and I'm glad to have had an opportunity to apply them!