drzk21632 2013-11-15 16:23
浏览 26
已采纳

适用于Api-Admin-Client应用程序的最佳ZF2架构

I have a ZF1 project that was developed used the lean startup approach. I'm now ready to move into a more evolved project as I know what my users want, but I really want to develop using better techniques. I've decided to move from ZF1 to ZF2 for support reasons and this is where I'm at:

API(Client) - I have a "push only' API that users use to send me data API(Admin) - The admins can consume the data pushed using a variety of metrics and aggregates

The API for clients is restful but just pushes into a Redis job queue currently and is processed via cron. This removes the need for clients to wait for their data to be inserted and their requests are returned immediately.

The API for admin is currently not restful and is actually consumed inside of the application only. I think that this is okay as I don't want to have a single page frontend or API consuming front end. I would rather data be returned immediately by the server.

This leaves me with the question of whether I have an API Service Module which provides all of the Models (Doctrine2 ODM POPOs), mappers, filters, and a service layer to access it all and then the controllers that need it can consume the API without making HTTP requests (via service calls).

Is this the proper way to structure or is there a more refined and acceptable approach? I like the service layer in general as testing will be more accurate and all clients / admins are using the same API (if it updates it is essentially updated immediately across the board as there are not separate projects).

  • 写回答

1条回答 默认 最新

  • dongpiao0731 2013-11-25 19:09
    关注

    I think the module you think of doesn't need to have an own built service layer which only forwards to another service (like Doctrine entitymanager or something else), it rather should only provide the other modules the required services by configuring the DI and encapsulate the required classes (like models, mappers, filters, ...).

    In my company for this purpose there is always an 'Application' module (like it was in the early tutorials of ZF2). I dont know if this is still best practice, but there are some serious benefits regarding maintainance and structure.

    You should consider defining a module dependency in the 'consuming' modules (like Client-API or Admin-UI).

    It is also worth to take a look at the Doctrine library and DoctrineModule implementation, to get a feeling what a module should provide and where it makes sense to only provide a library.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题