使用Zend Framework 3构建RESTful服务的最佳方法 [英] Best way to build RESTful services using Zend Framework 3

查看:108
本文介绍了使用Zend Framework 3构建RESTful服务的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在启动一个新项目,该项目将利用RESTful服务与Web客户端(AngularJS)和移动平台(Android和iOS)进行通信.

We are starting a new project that will make use of RESTful services to talk to web clients (AngularJS) and mobile platforms (Android and iOS).

这个想法是将业务逻辑隐藏在RESTful服务内部,并对Web客户端和移动平台使用相同的代码.

The idea is to hide the bussiness logic inside the RESTful services and to use the same code for both web client and mobile platforms.

我们的服务器是使用Zend Framework 3(我是该框架的新手)在PHP中构建.该应用程序将由数十个实体提供数百种服务.

Our server is being built in PHP using Zend Framework 3 (I´m new to the framework). The application will be have dozen of entities with hundreds of services.

我在网络上注意到ZF2似乎具有REST模块,但我找不到ZF3的模块(至少在文档中没有).

I´ve noted on the web that is seems that ZF2 has a REST module, but I can´t find one for ZF3 (at least not in the documentation).

我有一些问题:

  • 使用ZF3提供RESTful服务的最佳途径是什么?
  • 我应该安装ZF模块吗? ZF3是否已准备好使用一些东西?
  • 我是否应仅在代码中为我的服务创建一个模块?应该其他 模块将这个REST模块称为业务逻辑吗?
  • What is the best path to provide RESTful services using ZF3 ?
  • Shall I install a ZF module ? Is there something ready to be used that comes with ZF3 ?
  • Shall I create a Module in the code just for my services ? Shall the other modules call this REST module for business logic ?

推荐答案

ZF3仍带有AbstractRestController,可以在 ZF-Campus GitHUB存储库中找到:

ZF3 is still shipped with an AbstractRestController, which can be found here. Apigility could be a starting point for your REST application, but you could also consider implementing only some parts of Apigility and build your own logic on top of that. Interesting modules can be found in the ZF-Campus GitHUB repository:

  • ZF-Rest
  • ZF-Content-Negotiation
  • ZF-Content-Validation
  • ZF-Hal (depending on whether HAL-Json works for you...)

这些模块中的大多数(如果不是全部)都经过重构以支持ZF3(并与ZF2向后兼容).

Most (if not all) of those modules are refactored to support ZF3 (and backwards compatible with ZF2).

您自己浏览存储库,因为您可能会找到其他有用的模块.

Browse through the repository yourself because you might find additional useful modules.

这篇关于使用Zend Framework 3构建RESTful服务的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆