REST with PHP

Sunday, January 20, 2008

The simplest form of REST with PHP comes with XML + CURL. PHP can use the features available within the language to send and receive data, preferably in XML format in case of Web services, over HTTP. One of the most popular techniques is to use the CURL API and GET or POST contents to a URL. This naturally maps to the REST principles. This model is for client side, for consuming services.

For server side, going by the REST principles, one could argue, any hosted PHP script could be considered a REST service. Again, for the sake of Web services, to enable machine to machine interactions, rather than machine to human, XML would be the preferred form of input and output in case of a service. Again, nothing fancy is required, other than the current set of PHP API and extensions.

In short, REST with PHP is pretty simple.

7 comments:

Christian said...

you mean CURL, not CRUL ;)

Nexcet said...

at least the link is correct!
haha :o)

Sami said...

Ohhh, yes. Thanks for pointing out. Will fix that.

Dimuthu said...

In fact even without the CURL, PHP enable REST calls through fopen (with stream context). Just check out
http://www.php.net/stream_context_create

Dimuthu said...

You can find out how to build a SOAP and REST Service from PHP from this post.

Joe said...

this was the most pointless post ever. are you just trying to draw key word traffic?

dtrenz said...

I agree with Joe. This is a ridiculous post.

Dimuthu provided more information in the comments than you did in the post itself.

fail.