Best way to build RESTful services using Zend Framework 3

时间秒杀一切 提交于 2019-12-22 08:05:21

问题


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).

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.

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.

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).

Some questions I have:

  • 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 ?

回答1:


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...)

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.



来源:https://stackoverflow.com/questions/40922580/best-way-to-build-restful-services-using-zend-framework-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!