# Can we call php function in Rails?

**URL:** <https://www.ruby-forum.com/t/can-we-call-php-function-in-rails/172047>\
**Category:** Rails\
**Created:** [July 13, 2009, 9:50pm UTC](https://www.ruby-forum.com/t/can-we-call-php-function-in-rails/172047 "2009-07-13T21:50:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srinivas\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Srinivas\_I](https://www.ruby-forum.com/u/Srinivas_I)\
**Post date:** [July 13, 2009, 9:50pm UTC](https://www.ruby-forum.com/t/can-we-call-php-function-in-rails/172047/1 "2009-07-13T21:50:56Z")

</div>

Hi all ,

I have a small doubt , Can we call a php function in Rails . Is there  
any  
Interpreter or a Bridge in which Rails application can talk to a Php  
File  
and call a specific method from php file . Thanks in Advance

---

<div class="post-metadata">

**Author:** ![Srinivas\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Srinivas\_I](https://www.ruby-forum.com/u/Srinivas_I)\
**Post date:** [July 14, 2009, 12:26am UTC](https://www.ruby-forum.com/t/can-we-call-php-function-in-rails/172047/2 "2009-07-14T00:26:50Z")

</div>

Srinivas I. wrote:

> Hi all ,
> 
> I have a small doubt , Can we call a php function in Rails . Is there  
> any  
> Interpreter or a Bridge in which Rails application can talk to a Php  
> File

Not as such. I’d suggest either of the following two options:

- Treat your PHP app as an external Web service. This is simple and  
clean.
- If you really need PHP and Ruby playing in the same pool, try using  
Java, JRuby, and Quercus. But this is likely to be far more difficult.

> and call a specific method from php file . Thanks in Advance

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Srinivas\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Srinivas\_I](https://www.ruby-forum.com/u/Srinivas_I)\
**Post date:** [July 14, 2009, 7:03am UTC](https://www.ruby-forum.com/t/can-we-call-php-function-in-rails/172047/3 "2009-07-14T07:03:41Z")

</div>

Thanks Marnen for your Suggestions

Out of the two solutions you have suggested , which one will provide  
better performance ,

If i create the PHP app as an external Web Service and and call the  
method , My application should always be dependent on the Apache Server  
and this may afftect the performance of the Application and using  
webservice there may be time delay inorder to talk with the Apache  
Server  
and get the desired result

How about the Second option’s performance ? since i havent tried it  
.

Regards,  
Srinivas

On Tue, Jul 14, 2009 at 3:56 AM, Marnen Laibow-Koser \<

---

<div class="post-metadata">

**Author:** ![Srinivas\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Srinivas\_I](https://www.ruby-forum.com/u/Srinivas_I)\
**Post date:** [July 14, 2009, 8:34am UTC](https://www.ruby-forum.com/t/can-we-call-php-function-in-rails/172047/4 "2009-07-14T08:34:57Z")

</div>

Srinivas I. wrote:

> Thanks Marnen for your Suggestions
> 
> Out of the two solutions you have suggested , which one will provide  
> better performance ,

I have no idea.

> If i create the PHP app as an external Web Service and and call the  
> method , My application should always be dependent on the Apache Server  
> and this may afftect the performance of the Application and using  
> webservice there may be time delay inorder to talk with the Apache  
> Server  
> and get the desired result

Yes, that’s true. Is this a big deal?

> How about the Second option’s performance ? since i havent tried it  
> .

Neither have I. And I’ve only really used the first option in  
developing Facebook apps (and in those cases, it was wrapped by  
Facebooker).

> Regards,  
> Srinivas

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
