dongse7261 2009-11-25 23:56
浏览 60
已采纳

将Ajax / UI JS Framework(ext,jquery-ui)与MVC PHP框架(zend,symfony)结合起来是一个好主意吗?

I realize this is a very generic question, but I guess I'm not really looking for a definitive answer. Being new to PHP frameworks I'm having a hard time getting my head around it.

Javascript frameworks, especially with UI extensions, seem to have their sort-of MVC-like approach by separating your JS code from your design. It just seems like it would get confusing to use an additional MVC framework on the backend.

Is this commonly done for primarily AJAX-driven applications? Is there an accepted/common way of doing it?

  • 写回答

5条回答 默认 最新

  • douya1855 2009-11-26 00:10
    关注

    A quick example of how it can fit together for a Zend Framework app (and this is from a demo app I wrote a few months ago):

    • Use the MCV Framework to build a fully functional site (which works without javascript).
    • Modify the controller to understand the difference between a 'normal' request and an AJAX request (Zend's context switching makes this easy).
    • Add Javascript (in my example jQuery) to cleanly replace the links with AJAX events.

    In the end, the PHP app knows that an AJAX request needs an AJAX response (less bandwidth, less processing, only JSON or HTML 'snippet'), but a normal request needs an entire page generated.

    Basically, you're just using AJAX to request (or update, or add data to) the 'view' template, without having to process the entire layout. The Zend Framework Context Switch Action Helper may help this make more sense.

    It's worth mentioning that context switching works well in making a request available in different formats - HTML/XML,CSV,etc.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记