CakePHP, Rails respond_to equivalent
What's the best way to output different types of responses f.ex xml, json, html, rss etc. in the same controller action, 开发者_如何学运维and how would I send the preferred content-type to the action?
Ex. rails URLs:
- /user/add.xml = XML output
- /user/add.js = JS/JSON output
Having not really tried to achieve this I'm not too sure, but there is a chapter on this in the book, http://book.cakephp.org/view/174/Request-Handling which looks, at a skim, like it might cover what you need. It seems to revolve around processing the type of request.
I think what you want are web services. Lots of resources online.
ow-easy-are-web-services-in-cakephp-12-really-easy
cakephp-and-restful-web-services
精彩评论