Ruby Forum Test > Call Ruby from PHP

Posted by Bertran Biayna (beckbladerunner)
on 16.10.2007 10:08
Hi All,
I would like to know if it is possible to call a ruby script from PHP. I
developed a web interface connected to Data Base in PHP, but I would
like in some moment to call a ruby script that will perform some other
actions. Some ideas ? By the way I am thinking to move the whole PHP
system to ruby on rails, so everything will be in ruby, but maybe you
can give me some temporal solution. Thanks and Regards. Bertran.
Posted by Bertran Biayna (beckbladerunner)
on 16.10.2007 10:44
Bertran Biayna wrote:
> Hi All,
> I would like to know if it is possible to call a ruby script from PHP. I
> developed a web interface connected to Data Base in PHP, but I would
> like in some moment to call a ruby script that will perform some other
> actions. Some ideas ? By the way I am thinking to move the whole PHP
> system to ruby on rails, so everything will be in ruby, but maybe you
> can give me some temporal solution. Thanks and Regards. Bertran.

I will answer my self my question as I found the solution I needed... 
more simple impossible. Two scripts one in PHP and the other in ruby and 
the result is both are writng in same output in this case the html I am 
generating :

rubycall.php :
<?php
echo "lets call ruby from PHP :"
$s="ruby rubysayshello.rb";
system($s);
?>

rubysayshello.rb :
puts "ruby says hello from PHP !!!"

output :
  lets call ruby from PHP :
  ruby says hello from PHP !!!