开发者

Using Ruby library in PHP application

开发者 https://www.devze.com 2023-02-16 06:48 出处:网络
I am working on a PHP project that makes use of MLB\'s Gameday data.There appears to be a pretty solid Ruby library for working with data.I don\'t particularly want to rewrite the entire library in PH

I am working on a PHP project that makes use of MLB's Gameday data. There appears to be a pretty solid Ruby library for working with data. I don't particularly want to rewrite the entire library in PHP, so I was wondering if anyone had any suggestions for a good way to interact with the Ruby scripts from my PHP application.

I'm starting to think that I'll need to write some sort of command line Ruby script that'll interact with the Ruby classes and output the data in a format usable by PHP 开发者_运维百科(JSON, XML).

Are there any better ways to do accomplish this?


Another option is to use Gearman, written by the the same team that brought us memcached. It has PHP and Ruby bindings.

You'd create a daemon in Ruby that exposes functions to Gearman, then have your PHP code call those functions through Gearman. No Apache needed.

(Boy, I'm on a Gearman plugging streak. I wish I was getting paid for it!)


Rather then a command line interface, I'd suggest outputting data in JSON format and requesting that data via PHP & CURL.

If you needed to you could even write a REST interface for it pretty easily.

0

精彩评论

暂无评论...
验证码 换一张
取 消