phpajaxzend-frameworkarchitecturezendx

AjaxContext vs Controller_Ajax in Zend Framework app


This is a question about the architecture.

I've seen two approaches implementing AJAX layer in Zend Framework.

The first one, traditional, using AjaxContext action helper (index.phtml and index.ajax.phtml). This has always a nice fallback when no JavaScript is available.

The second one, implementing separate controllers for AJAX (disable the layout by default etc.)

I wonder about the possible advantages and drawbacks of those two solutions in the long run.

Which one would you recommend and why?

(I'm using ZendX jQuery)


Solution

  • I would only implement different controller actions if they had to do something different at that level. Rendering a specific view based on the request method is not cause for a new action method.

    My vote goes to AjaxContext.