Welcome Guest, Not a member yet? Register   Sign In
RESTful Web Services
#1

[eluser]dondani[/eluser]
Hi people,

Congratulations for the great community you have developed around this great piece of software.

My question: is it possible to develop RESTful web services with CodeIgniter (or with PHP in general)?

I've been investigating a bit, and have found two frameworks: Tonic (quite old, looks abandoned) and Konstrukt (just starting). I haven't delved into their code yet.

There aren't many articles that touch this subject either. I've found this:
http://www.onlamp.com/pub/a/php/2003/10/..._rest.html
It only shows how to consume RESTful web services (using cURL), but not how to create one.

Also, a book about RESTful web services has just come out:
http://www.oreilly.com/catalog/9780596529260/
It talks about Ruby on Rails, Restlet, and Django, but sadly no PHP!

I would appreciate any kind of information you can give me. Thank you.
#2

[eluser]gunter[/eluser]
why not! you pass data in the url to CI -> and CI answers... or does something...
and is answering.
if I would do it for myself, then I would just pass back a serialized array...

(but thats my personal opinion, I never made my own REST service)
http://www.xfront.com/REST-Web-Services.html is a nice intro...
#3

[eluser]dondani[/eluser]
Yup, for GET messages (/articles/view/17) no problem, same as with POST (/articles/update). That's what we use every day.

But HTTP also defines PUT and DELETE, and I don't know how to handle those. I could simulate those actions using POST with dedicated URLs (/articles/create, /articles/delete), but I was trying to do pure REST, so that it can be used not only from the browser, but from other applications.
#4

[eluser]esra[/eluser]
Many of the Zend Framework libraries can be used with CI, and there is a REST library.
#5

[eluser]dondani[/eluser]
Will look into that.

I have also been investigating Ruby on Rails 1.2, which appears to have REST support out of the box, and 2.0 will be even more oriented towards RESTful web services. From what I've read, Ruby's performance is nowhere near PHP's, but I'll have to keep an eye on it.

Thanks for your suggestions!
#6

[eluser]marcoss[/eluser]
I would go with Atom, REST is old, and it does not make your life easier as it preaches.

Now, regarding PUT and DELETE, get rid of them, nobody use them, firewalls block them of and again, nobody in the real world use them, juts follow this rule, GET to read, POST to edit, delete and create. It works, and it works pretty well.
#7

[eluser]dondani[/eluser]
As a matter of fact, that's what Google is doing with their GData APIs, everything Atom...

I had overlooked that possibility. Great advice, thanks.
#8

[eluser]cbmeeks[/eluser]
[quote author="marcoss" date="1187444007"]I would go with Atom, REST is old, and it does not make your life easier as it preaches.

Now, regarding PUT and DELETE, get rid of them, nobody use them, firewalls block them of and again, nobody in the real world use them, juts follow this rule, GET to read, POST to edit, delete and create. It works, and it works pretty well.[/quote]

Sorry to drudge up an old topic but I was searching though CI for RESTful examples.

That is a fairly bold statement you just made. And after reading (and LOVING) the RESTful book, I would say that is hogwash.

However, I can't help but somewhat agree. I think a lot of people are using it. But, the firewall issue has me concerned. I never thought of that.

I am building an application now that uses C# (client side). My app will access a MySQL db though REST calls. I was hoping to use the "traditional" method of REST.

I played with RoR for a while and they had a way to "fake it". Where basically you coded the RESTful way but the framework translated PUTs into POSTS, etc. It worked but seemed to be kludgey.

C# makes it easy to send real PUT requests. And PHP/CI should be able to handle them. But I am really wondering "Is it worth it?"

Anyone else have an opinion on this?

Thanks.
#9

[eluser]tonanbarbarian[/eluser]
I do not think anyone truely builds REST using the PUT and DELETE methods because there is no guarentee that a webserver will support those method. If the firewall does not block it the Webserver might.
About the only webserver I can think that might support it without configuration is IIS and maybe only in version 4. I think 5 and 6 with the added layers of security probably limit PUT and DELETE unless allowed.

So I think most people who implement REST on a webserver just use POST methods to do this.
#10

[eluser]cbmeeks[/eluser]
[quote author="tonanbarbarian" date="1196410434"]I do not think anyone truely builds REST using the PUT and DELETE methods because there is no guarentee that a webserver will support those method. If the firewall does not block it the Webserver might.
About the only webserver I can think that might support it without configuration is IIS and maybe only in version 4. I think 5 and 6 with the added layers of security probably limit PUT and DELETE unless allowed.

So I think most people who implement REST on a webserver just use POST methods to do this.[/quote]

No, I have actually done it with Python and Ruby to an Apache web server. But I controlled the server so I know it can be done.

I think most people use POST/GET only because it's easier. But I'm really wondering about the security now.




Theme © iAndrew 2016 - Forum software by © MyBB