Is there any way to include php file using require and calling a php method in rails application ? I dont want to use phusion passenger as my server .
-
1Wait... Why exactly do you want to do this?Sasha Chedygov– Sasha Chedygov2009-07-07 05:28:46 +00:00Commented Jul 7, 2009 at 5:28
-
I am testing a sample application which integrates php application and rails application , i dont want to make a request to the php application instead i have to include the php file and call the php method from rails application . Is it possible ?Srinivas M.V.– Srinivas M.V.2009-07-07 05:31:52 +00:00Commented Jul 7, 2009 at 5:31
-
Yes it's definitely possible, but I doubt it will be very pretty. But I'd be interested to see what people here come up with. Good question.Sasha Chedygov– Sasha Chedygov2009-07-07 05:36:49 +00:00Commented Jul 7, 2009 at 5:36
2 Answers
As far as I know, there is no PHP interpreters for Ruby, so your best bet would be to make an HTTP request from your Rails app to your PHP app to get its output. This of course won't allow you to directly call any specific function or such.
It might also be possible to run your Ruby application using JRuby, and at the same time, use Quercus. Quercus is a Java based PHP interpreter, so you might be able to interact through the JRuby Java interface with the Quercus parsed PHP script.
Disclaimer: Never used Ruby, JRuby or Quercus.
Comments
You could just run it through a shell command. There are several ways to do it, but here's one:
`php /path/to/your/script.php`
This will run the PHP script in the argument. If you care about the result of the script:
result = `php /path/to/your/script.php`
Disclaimer: I've never actually tried this so I don't know what it returns, but theoretically it should return whatever the script returns, if anything.