I’m writing an application in ruby and would like to access some legacy code written in another language (php). Unfortunately this legacy code does not have an HTTP API, but it is living on the same file system. I had the idea that maybe instead of building an API, or rewriting all of the code in ruby, there may be some clever way I can expose these PHP functions so ruby can access them. Do you have an idea or approach I can use to accomplish this?
Share
Assuming you mean code that is callable at the command-line, using either backticks or the
%xoperator or the more complexsystem,popenandpopen3commands lets you execute separate pieces of code and gather the results.For instance in IRB:
Wrap that in a method and it becomes a way to call an external program:
See “Ruby, Difference between exec, system and %x() or Backticks” for additional information.