3

I'm trying to come up with a solution to this problem. I have a Ruby script that needs to run some PHP code, but I am new to Ruby, so I don't know how to go about doing this.

def run_my_code
    #execute some PHP code here
    # $person = new Person();
    # $person->doSomething();
end

How can I achieve this?

2

3 Answers 3

5

one way is to use exec

http://ruby-doc.org/core/classes/Kernel.html#M005968

also `ls` or `cmd` works too (back tick)

Sign up to request clarification or add additional context in comments.

1 Comment

does it cost much to frequently spawn new processes just to eval a PHP code?
3

I've heard of Phuby, though I haven't used it myself.

Comments

2

Look at Erubis. It supports PHP and other languages (Ruby/PHP/C/Java/Scheme/Perl/Javascript).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.