Zend_Rest_Server 可以返回 Json 吗?
如果没有,有什么替代方案(其他库建议也可以)
Zend_Rest_Server 输出 XML,尽管文档中没有明确指定。
有一些替代方案:
您可以利用 Zend Framework 提供的整个 MVC 架构,这要归功于Zend_Rest_Route
and Zend_Rest_Controller
.
您可以在这里找到完整的示例:
http://techchorus.net/create-restful-applications-using-zend-framework http://techchorus.net/create-restful-applications-using-zend-framework
同样,该示例显示纯字符串,但使用json_encode
, or Zend_Json::encode
应该返回 json。
最后,一个完整的(高级)示例使用ContextSwitch
特征:
http://www.chrisdanielson.com/2009/09/02/creating-a-php-rest-api-using-the-zend-framework/ http://www.chrisdanielson.com/2009/09/02/creating-a-php-rest-api-using-the-zend-framework/
(如果您需要更多信息ContextSwitch
Action Helper,请参阅文档。)
不幸的是,我有限的声誉阻止我给你更多的链接,但谷歌是你的朋友,使用一些神奇的词,例如zend rest json
or zend controller rest json
...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)