Executing php code in rails app

Hi all,
This might sound weird!!!
If I want to include/execute simple “helloworld” inside my rails
application (actually I want to integrate some php applications…) what
need to be done. If I am not wrong this is possible and could anyone
please give me more info on this or redirect to already available
examples…

Thanks,
Sumanth.

You could use the php command line:

test.php:
print "Hello, world!;

test.rb
php_output = php test.php

Or just to exec and directly output use: system “php test.php”

Ofcourse, php cli must be available.

Wouter De bie wrote:

You could use the php command line:

test.php:
print "Hello, world!;

test.rb
php_output = php test.php

Or just to exec and directly output use: system “php test.php”

Ofcourse, php cli must be available.

Hi Wouter,
Thanks for your reply. What I am looking is how to execute these php
files in rails application (project). Precisely, where to keep the php
files, how to execute these php files from rails controllers, and what
to do to integrate the php application databases…

Thanks,
Suamnth Krishna.A

OK I’m not even going to ask why you would want to do that, but you
can keep your files wherever you like, and just execute them as
scripts. But they won’t work in that same way ruby scripts do with
other ruby scripts, you can use functions written in PHP and call them
directly in Ruby, you’d need to execute an entire script.

If you don’t mind me asking, why the heck would you want to do this???

If you have some massive legacy app or something, I can’t imagine why
you’d be porting “bits” of it to rails. You could also always write a
web sevice with SOAP or XML or something and connect to that with Ruby
and then use that…

Long and the short of it, you can call any php script with something
like:
exec ‘php filename.php’

Cam

On Jul 16, 3:23 pm, Sumanth A. [email protected]