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 loca
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?
well, does system('php public/php_script.php')
work?
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.
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