News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthew Weier O'Phinney's Blog:
Responding to Different Content Types in RESTful ZF Apps
March 05, 2010 @ 12:20:22

Continuing on from his previous articles on working with REST in Zend Framework applications (and making the endpoints for a web service) Matthew Weier O'Phinney has a new tutorial with the next logical step in the series, automatically responding to different content types in your application based on the content-type the client sends.

There's no reason you can't re-use your RESTful web service to support multiple formats. Zend Framework and PHP have plenty of tools to assist you in responding to different format requests, so don't limit yourself. With a small amount of work, you can make your controllers format agnostic, and ensure that you respond appropriately to different requests.

He talks about concerns you'll have to worry about when developing your service - grabbing teh raw input instead of the POST values (since most requests will be rawly POSTed) and what to pass that message to to decode it properly. In his example the Zend_Json and Zend_Config_Xml components make it simpler to handle the info and some code to get the results back into your script.

There's also some code for the other side of things - building the response and pushing it out to the correct views depending on the request content type, action and information.

0 comments voice your opinion now!
zendframework rest webservice contenttype json xml tutorial


blog comments powered by Disqus

Similar Posts

Community News: Adobe Seeks PHP Developers for Pre-Release Access on Flex Builder

TechChorus Blog: Create RESTful Applications Using The Zend Framework - Part II: Using HTTP Response

HowTo Forge: Installing Lighttpd With PHP5 And MySQL Support On Mandriva 2008.0

Michael Nitschinger: Caching Doctrine Entities with Couchbase

Benjamin Schneider's Blog: Use PHP's Tidy extension to validate your (X)HTML markup


Community Events





Don't see your event here?
Let us know!


podcast release opinion package bugfix framework api voicesoftheelephpant library language install community laravel tips interview series list symfony deployment introduction

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework