2

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

1

1 Answer 1

3

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 ...

Sign up to request clarification or add additional context in comments.

2 Comments

Zend_Rest_Server is only working with XML. You can't decide the ouput format.
After some testing, I have edited my answer as the initial example was not working. I have not fully tested it, but the Zend_Rest_Controller and ContextSwitch should (must) be working ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.