Run a php script in ruby on rails

In one of my Rails application I need to execute a PHP file from the Controller of Ruby on Rails app. The PHP file meant for some database editing.

The php file located in my "public" folder

Is there is any way for doing that?


If you want to talk to the process in some way, use IO.popen("php <script>"). Or you could use the backticks option (not easy with the markup here), which returns the string the process writes to stdout. If you need no communication, system "php <script>" returns you true or false wherever the command succeded and you've got no chance to communicate further.

If you have unsafe input, use Array#shelljoin to escape it.

Why not rewrite the script in ruby?

Try `php #{RAILS_ROOT}/public/php_script.php` or %x["php #{RAILS_ROOT}/public/php_script.php"]

System command doesn't work in rails but some code like the above should be ok.

well, does system('php public/php_script.php') work?

My problem solved by this line in my Controller

result = D:\\rails\\php\\php.exe -f D:\\Rails\\rails_apps\\project\\public\\df.php po

Need Your Help

pass an array objects in Corona with class

android class lua corona

I'm creating an app with Corona structured in Class and I have a problem when I want pass an array objects for create an object.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.