# Begining with Ruby

**URL:** <https://www.ruby-forum.com/t/begining-with-ruby/158184>\
**Category:** Ruby\
**Created:** [January 20, 2009, 9:34am UTC](https://www.ruby-forum.com/t/begining-with-ruby/158184 "2009-01-20T09:34:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mudgilgaurav](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bcef8e/32.png) [@mudgilgaurav](https://www.ruby-forum.com/u/mudgilgaurav)\
**Post date:** [January 20, 2009, 9:34am UTC](https://www.ruby-forum.com/t/begining-with-ruby/158184/1 "2009-01-20T09:34:10Z")

</div>

Hi All,

I am new to ruby and i want to develop an web service in ruby that will  
be invoked by the PHP application and will return the output to the PHP  
variable.

Please suggest me how i should proceed in terms of learning ruby and  
developing my web service.

Any help or suggestion would be greatly appreciated.

Thanks  
Gaurav

---

<div class="post-metadata">

**Author:** ![mudgilgaurav](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bcef8e/32.png) [@mudgilgaurav](https://www.ruby-forum.com/u/mudgilgaurav)\
**Post date:** [January 20, 2009, 10:29am UTC](https://www.ruby-forum.com/t/begining-with-ruby/158184/2 "2009-01-20T10:29:28Z")

</div>

Gaurav S. wrote:

> I am new to ruby and i want to develop an web service in ruby that will  
> be invoked by the PHP application and will return the output to the PHP  
> variable.
> 
> Please suggest me how i should proceed in terms of learning ruby and  
> developing my web service.

Well, there are several different ways you could get your PHP front-end  
to call your Ruby web service, such as:

- REST (HTTP GET / POST / PUT / DELETE, usually with XML parameters)
- SOAP
- xmlrpc

I’m afraid I don’t know which of these has the easiest or most robust  
PHP client support. However I personally wouldn’t choose SOAP unless it  
was forced on me, as it’s a horrendously complex beast. (It’s fine as  
long as the APIs are hiding the complexity; the problem is debugging it  
when it isn’t working)

For the Ruby backend, there are a variety of web frameworks out there  
that you can consider.

If you’re learning from scratch I’d suggest Rails, primarily because  
there are plenty of excellent books you can buy. I have the [PragProg.com](http://PragProg.com)  
books: “Agile Web D. with Rails” and “The Ruby P.ming  
Language” (\*) and they suit me very well, but there are plenty of others  
to choose from.

Rails supports REST natively, and SOAP as a plugin. However, Rails is  
big so there’s a lot to learn, and a lot of HTML-generation  
functionality may be irrelevant to you initially.

For a really simple REST backend you could consider Sinatra, as you can  
write apps which are just a handful of lines of code. You’ll need to add  
a database access layer of your choice - e.g. ActiveRecord from Rails,  
or Sequel or Datamapper. Again, if you choose ActiveRecord then you’ll  
find lots of Rails books with good coverage.

If you want to use xmlrpc then there is a simple xmlrpc server included  
in the Ruby standard library. This should be fine under small loads, but  
it may not scale as well as other solutions (since it’s based on  
WEBrick, and as far as I know it doesn’t give you the options of using  
mongrel / thin / rack / phusion passenger etc.)

Of course, once you’ve learned Ruby, you may find you want to ditch PHP  
for the front-end and use Ruby there too 🙂

BTW a similar question was asked here about 3 days ago, so have a look  
at that too: [Desktop \<-\> Web - Ruby - Ruby-Forum](http://www.ruby-forum.com/topic/175849)

Good luck,

Brian.

(\*) The old, first edition of the Programming Ruby book (for ruby-1.6)  
is available for free on-line:  
[http://www.ruby-doc.org/docs/ProgrammingRuby/](http://www.ruby-doc.org/docs/ProgrammingRuby/)  
This is a good starting point before you decide to invest in a newer  
book.
