views:

71

answers:

3

I want to create a REST service with PHP 5. I'd appreciate it if people would recommend some guides/tutorials on the subject. I'd like tutorials that cover the whole process, including the creation, securing and deployment of the service. Thanks.

A: 

You could check out the wiki page on it. There is some abstract explaination on the matter.

For more concrete implementation take a look at the Zend package wich I use to build REST services.

jpluijmers
A: 

I've been planning on building a full API/REST interface as of yet I've only implemented some features. The key concept that you need to get around is that it is simply a XML/JSON (etc) response to a predefined url.

You can quite easily get set up using .htaccess & mod rewrite to allow domain.com/method/var/id or some similar structure to redirect to domain.com/script.php?method=method&?var=var&?id=id . Once this is done, you can use these in your script, create your response and return it(print/echo) to script.php .

When a user sends a request, they will received the result that you have specified.

Json is very easy to use and implement thanks to http://php.net/manual/en/function.json-encode.php

You want to look into mod rewrite for apache.

As for authentication, it shouldnt differ to any other login/authentication have a look at sessions for php. http://php.net/manual/en/features.sessions.php

Hope this helps.

Jamie
One of the powers when using REST is that it should work stateless. So no session is kept on the server but instead all session data is kept in the client.Think of REST urls of resources uppon wich sertain actions can be executed given a set of parameters.
jpluijmers
A: 

I have always used the Zend_Rest libraries when trying to accomplish this task. They are pretty easy to implement and pretty well documented.

Zend_Rest

robedge