It is not necessary to implement my RESTful web service on the top of Zend Framework as RESTful Web service is just a simple map between CRUD operations and HTTP verbs. But, Zend Framework has handy classes like
Zend_Rest_Controller
and Zend_Rest_Route
. Using these two classes, I can easily to implement RESTful Web service having URI template as http://hostname:port/restService/paraName1/paraValue1/paraName2/paraValue2 . In Zend Framework, there are two design patterns implemented. One is front controller design pattern. The other is MVC design pattern. Since RESTful web service is stateless and it does not need MVC pattern, implementing login module in a controller plugin module will be best seamless solution for RESTful Web service in Zend Framework. Only Zend Framework front controller pattern is involved in the processing of RESTful web service.I regard my login module as a filter, which is well known concept in Java servlet. For my RESTful Web service, I put this filter in function
void Zend_Controller_Plugin_Abstract::routeStartup (Zend_Controller_Request_Abstract $request)
. Therefore, the authentication process happens even before the action dispatch will happen. Below is a simple version diagram to show the position of RESTful login module in Zend Framework dispatch process.