A WordPress plugin that depends on Ruby will not be portable. This is normal if you are the only one who will use it.
If a Ruby script should return a result that will immediately be used by the PHP script that calls it, then something like exec () is the only way. Make sure you avoid any arguments that you pass to the Ruby script; otherwise, you will be vulnerable to injection attacks.
If the Ruby script does not need to immediately return the result (for example, some background processing, for example thumbnail generation), then I think the best way for a PHP script is to insert a string into a MySQL database or something like that. Ruby script can run in the background or run from cron, periodically check the database for new tasks and perform any necessary processing. This approach avoids the performance and security issues of exec (), and possibly is also more scalable. (A similar approach would make Ruby script listen on the socket, and your PHP scripts would connect to the socket, but this requires more work to get everything right.)
source share