I'm developing a Zend Framework based application and I found myself writing a skeleton for the API module. I read a bit on the web and I started writing the skeleton based on Zend_Rest_Controller
. Turned out ok, key login required to use the API.
The questions started when a colleague of mine started implementing the skeleton in a proper API for one of our applications. He 开发者_C百科told me he thinks it would be better if we only had an usual Zend_Controller_Action
extended in an API controller and in indexAction
a Zend_Rest_Server
that handles the object.
I'm a bit confused about this. From my personal point of view I'd want to have a "larger-than-average" controller containing each of the 4 actions (get, post, put, delete) and a bit of logic in each action rather than one action ruled by Zend_Rest_Server
.
My problem is that I can't figure which of the 2 solutions is better from an architecture point of view; and of course, the most easily maintainable over time.
Zend_Rest_Server is generally considered deprecated in favor of Zend_Rest_Controller/Zend_Rest_route. See this post by MWO'P, for instance.
This alone would push me firmly in the direction of Zend_Rest_Controller/Zend_Rest_Route.
If you want to do REST on Zend I suggest you take a look at the Resauce Framework
精彩评论