NYCPHP Meetup

NYPHP.org

[nycphp-talk] JSON and MVC

Paul A Houle paul at devonianfarm.com
Wed Jul 22 09:51:38 EDT 2009


    I'd say that practically frameworks need to have some way to disable 
the "view" layer,  at least the HTML templates,  to let a controller 
output raw data.

    In my experience,  for instance,  business applications often need 
to output csv or xls so that people can load content into a 
spreadsheet.  Often you want to be able to format (nearly) the same 
content in different ways.

    I'm working on a public facing app that's oriented towards the 
semantic web;  all pages are available in HTML,  RDF/NT and RSS 
formats.  Content is ~almost~ the same,  but not quite.  HTML output is 
paged in order of relevancy/quality (the page on topic X shows the top N 
content items related to topic X;)  RDF format offers a unpaged dump of 
triples related to topic X (all of the triples that come from traversing 
the relationship tree coming from X in a specified way);  RSS offers a 
limited number of items ordered by recency -- people can subscribe to a 
page via RSS and get updated when new content gets added.

    The framework involves a certain amount of codesign between models,  
views and controllers -- it's designed to produce a family of related 
sites with high reuse,  not to be a system for building general business 
apps like Rails/Symfony/Cake...

    Administrative functions (editing content) are implemented in an 
AJAX-heavy manner,  where the role of "MVC" is quite different from 
traditional.  Layout templates aren't as important as a in conventional 
webapp,  since we're not redrawing the page each time.   However,  in an 
AJAX application,  the framework still must handle authentication for 
requests,  and also needs to have a systematic way to bolt in business 
rules and handle violations.




More information about the talk mailing list