Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what idea is behind Zend Framework Frontcontroller/dispatcher

Zend Framework FrontController implements Singleton and plus it has some kind a plugin "paradigm" , - what is the idea behind its architecture , maybe it implements some well known paradigm ? and if so then if u could give some links directions where I can find information about reasons that brought up that particular paradigm ?

like image 253
simple Avatar asked Feb 28 '23 06:02

simple


1 Answers

The basic idea of a FrontController is to provide for a single point of entry to your application.

Quoting PoEAA:

The Front Controller consolidates all request handling by channeling requests through a single handler object. This object can carry out common behavior, which can be modified at runtime with decorators. The handler then dispatches to command objects for behavior particular to a request.

Further definitions:

  • http://en.wikipedia.org/wiki/Front_Controller_pattern
  • http://java.sun.com/blueprints/patterns/FrontController.html

Also see the chapter in the reference guide about the Front Controller:

Zend_Controller_Front implements a » Front Controller pattern used in » Model-View-Controller (MVC) applications. Its purpose is to initialize the request environment, route the incoming request, and then dispatch any discovered actions; it aggregates any responses and returns them when the process is complete.

About being a Singleton

Zend_Controller_Front also implements the » Singleton pattern, meaning only a single instance of it may be available at any given time. This allows it to also act as a registry on which the other objects in the dispatch process may draw.

For a General Definition of the Singleton and the Registry pattern see:

  • http://sourcemaking.com/design_patterns/singleton
  • http://martinfowler.com/eaaCatalog/registry.html

About being pluggable

Zend_Controller_Front registers a plugin broker with itself, allowing various events it triggers to be observed by plugins. In most cases, this gives the developer the opportunity to tailor the dispatch process to the site without the need to extend the front controller to add functionality.

A good detailed explanation how Zend Framework uses the Front Controller and what happens under the hood during an MVC rquest can be found in:

  • Zend Framework MVC Request Lifecycle
like image 126
Gordon Avatar answered Mar 05 '23 12:03

Gordon