OK, I am creating a grails project, but I have php legacy code. Rather than re-invent the wheel, is there a way to call the php code from my groovy?
For example, there is a php script called post_handler.php that has a postRequest method that has $data (the data required to do the post) as the input param. How would I go about just calling post_handler->postRequest(data)? I’m sorry if this question has already been asked and answered. I looked and couldn’t find anything.
Thanks in advance.
I would probably put a thin API on top of your PHP code that would allow you make REST calls that return JSON. You can then very easily use your existing PHP as a data layer if you so choose. You can use HttpBuilder to very easily make calls to an external REST service and then it will demarshall the JSON string to an object.
If a web service is too slow for your communication layer, you may want to look at Thrift. Facebook uses this to communicate between PHP and Java. There are some tutorials here if you want to check it out.