NYCPHP Meetup

NYPHP.org

[nycphp-talk] JSON and MVC

Nate Abele nate at cakephp.org
Tue Jul 21 13:08:19 EDT 2009


On Mon, 20 Jul 2009, Hans Zaunere wrote:

> I think this really begs some questions on current server-side  
> frameworks
> and the MVC methodology.  Changes like this have already begun,  
> namely in
> RoR and other platforms.

In Cake 3.0 we have a class called Media (http://code.cakephp.org/cake3/source/libraries/cake/http/Media.php#47 
) that sits between the controller and view layers.  Instead of  
worrying about context switching, you can attach handlers that work  
across your whole application, and respond for each different media  
type.  Handlers can be a specific view class (the default, as in the  
case of HTML, etc.), a reference to a class method or function (i.e.  
"json_encode" for JSON) or a closure where you can define custom rules  
or transformations.

The great thing is, while handlers can be overridden on a case by case  
basis, once they're attached, you never need to think about them  
again, they just work; and all the switching logic is kept out of your  
controller.

- Nate Abele
   Lead Developer, CakePHP

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090721/fae8e15a/attachment.html>


More information about the talk mailing list