Zend Framework has a very neat action helper called ContextSwitch. With this helper you can easily output data from your actions in other formats besides HTML. For instance, when you create an AJAX-callback action, you’d like to have the output in JSON format, or simple API actions might output its content in XML. The ContextSwitch makes this task easy for you. But what if you are writing an API and a client wants its output in JSON instead of XML? Or maybe it wants HTML. You could use the ContextSwitch helper for this, but do you want to add a ?format=xml behind your URI’s or might there a better way? read more…

Volg ons