0

当我从 Zend_Rest_Controller 扩展一个类时,实现了 5 个抽象方法(index、get、put、delete、post),用于 CRUD。

我的项目结构是

 -application
     - config
     - controllers       // used for our web controllers
     - emails
     - forms
     - views
     -Bootstrap.php
-library
  -CustomLibrary // Libraries for our project
  -Frontend
   -Action.php //this is extends Zend_Action_Controller and I added some customize code

我想为我的应用程序创建一个 Web 服务,以便在我们的 Android 应用程序上使用它,我想返回 Android 应用程序 JSON 对象和参数。我研究并询问了stackoverflow,我发现Rest Controller是使用它的方式。我的问题:在这种情况下使用 Zend_Rest_Controller 是否正确?
- 如果是,我不能写更多的动作,我只使用抽象的动作,我需要的不仅仅是那些动作,比如(registerAction()、getAllNewsAction() 等......)还是我应该为此使用更多的类?


如果否,使用什么?以及将这些 api 类放在哪里(在同一个控制器文件夹中或将其放在 Library 文件夹中)

4

1 回答 1

0

如果您使用 RESTful 架构,您总是有以下 GET-、POST-、PUT-、DELETE-操作之一。在 ZF2 中,这意味着您在 Controller-Class 中实现了以下操作:indexAction (GET-Request)、getAction (GET-Request)、postAction (POST-Request)

您需要的其他方法是通过您传递给上述请求的参数来控制的。看看这个教程:http ://www.techchorus.net/create-restful-applications-using-zend-framework

于 2013-04-10T14:42:08.600 回答