doukucai0099 2011-04-21 21:09
浏览 29

如何为Ajax(Extjs)-PHP应用程序设计Controller?

The application is being designed with ExtJs, (Json), PHP, and MySQL. More than half of the logic/Model will be on the server side. While significant chunk of the logic is with the ExtJs Frontend. This is mostly a Single Page Application, so the traditional MVC Front End Controller/Routing does not work here. I would still like to design a php Controller that manages the interactions with the server. How best to do this?

  • 写回答

1条回答 默认 最新

  • du4373 2011-04-21 22:39
    关注

    I would suggest thinking of the server in terms of a "web service". Essentially, your ExtJS front-end code would be the application, and your back-end "web service" would only provide ways to fetch and store data.

    Basically it would be something like this:

    • ExtJS based "UI layer"
    • JavaScript based "controller layer" works with the UI layer
    • PHP based "service layer"
    • The UI layer interacts with the controller layer, which then interacts with the service layer

    The service layer would essentially be the same as in any typical PHP web app: It would contain data validation, input filtering, database queries, all the usual stuff. The main difference would be that instead of using PHP to generate HTML that would then be sent to the browser, the service layer would only serialize the results into JSON.

    The controller layer in the JS code would perform Ajax requests to the services. It would process the JSON results, and tell the UI layer what it should display. It would also contain methods which handle events from the UI.

    The UI layer would simply act sort of like a template engine or your HTML code. It would display data assigned to it from the controller layer, and it would call functions in the controller layer to handle events like pressing buttons.

    评论

报告相同问题?

悬赏问题

  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致