News Feed
Sections




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

Enrise.com:
REST Style Context Switching - Part 2
January 13, 2011 @ 12:48:57

Joshua Thijssen has written up a new post for the Enrise blog today about using REST-style context switching in Zend Framework applications with the help of a handy "RestContextSwitch" helper.

In the first part of this blog post we've talked about the theory behind REST services. In this post we put the theory into practice with the help of some code snippets you can implement in your own application.

He starts by helping you create a simple REST controller (well, cut-and-pasteable code, really) that can handle multiple output formats/contexts - XML, JSON and HTML. Next up is the helper (Service_Controller_Action_Helper_RestContextSwitch) that's not much different than the normal context switching helper. With that in place he moves on to the plugins - an accept-hander that sets the correct format based on the Accept HTTP header information and a media-format plugin to check "permissions" on the context to see if that type is allowed in that environment.

0 comments voice your opinion now!
rest zendframework context switching html xml json


blog comments powered by Disqus

Similar Posts

Juozas Kaziukenas' Blog: SQL Native Client as MSSQL driver for Zend Framework

Padraic Brady's Blog: Zend Framework Blog Tutorial - Part 8: Create/Add Blog Entries (HTMLPurifier)

Zend Developer Zone: PHP: Performance, Scalability, and Web Services Podcast

Zend Developer Zone: ZendCon 2010: 3 Questions with Matthew Weier O'Phinney

Project: Aleksey Martynov's lexa-xml-serialization Tool for PHP 5.3


Community Events





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


api unittest threedevsandamaybe wordpress interview application release list community series configure bugfix code introduction laravel install library language developer podcast

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