2
votes

Can Zend_Rest_Server return Json ? If not, what are the alternatives ( other lib suggestions are ok also)

1
Zend_Rest_Server is deprecated, you should use Zend_Rest_Controller et al instead. Also see Examples of building a REST API server using Zend Framework?.wimvds

1 Answers

3
votes

Zend_Rest_Server outputs XML, eventhough not clearly specified in the documentation.

There are some alternatives:

You could leverage the whole MVC architecture given by Zend Framework, thanks to Zend_Rest_Route and Zend_Rest_Controller.
You will find a complete example here:
http://techchorus.net/create-restful-applications-using-zend-framework

Again, the example displays plain string, but using json_encode, or Zend_Json::encode should return json.

And finally, a complete (advanced) example that use the ContextSwitch feature:
http://www.chrisdanielson.com/2009/09/02/creating-a-php-rest-api-using-the-zend-framework/

(If you need more information on ContextSwitch Action Helper, please refer to the documentation.)

Unfortunately, my limited reputation prevent me from giving you more links, but Google is your friend using some magic words such as zend rest json or zend controller rest json ...