Tag Archives: front_controller

Zend Framework – quick tutorial (part 3) – front controller plugins

Why writing a front controller plugin?

Almost every application uses a database connection and acl module. Why doing this in the bootstrap and to mantain many lines of code there, instead of making it clear and mantainable. Of course you can have all these lines of code in your bootstrap, but you know for serious applications that recently will become an obstacle. That’s why Zend Framework allows you to use Front_Controller plugin.

First in you bootstrap add those lines of code

/*
 * add a simple plugin to the controller
 */
 
$front->registerPlugin(new Zend_Controller_Plugin_Init())
      ->registerPlugin(new Zend_Controller_Plugin_Acl());

These two classes (Zend_Controller_Plugin_Init and Zend_Controller_Plugin_Acl) should be placed in two different files with the same names in Controller/Plugins directory under Zend folder, and garantee you that both classes will be instanciated before starting the front controller. Continue reading Zend Framework – quick tutorial (part 3) – front controller plugins

Zend_Controller_Front plugins

Една от особеностите на Zend Framework Front Controller е фактът, че може лесно да се напишат и ползват plugins към него. Колкото до официалната документация на ZF, поне според мен, не е достатъчно описателна и не дава ясна представа какво точно правят тези plugins и колкото и добре да е показано как се пишат и как са замислени не става известно какво предимство дават на приложението.

Добра статия за това как да се напише plugin и какви предимства дава може да се намери в една статия, която намерих днес.

Ето и някои от предимствата на плъгините:

  1. Инициализация на приложението
  2. Кеширане
  3. Инициализация на router-а
  4. Authentication и Authorization
  5. Филтриране на изходния XHTML