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 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退