Zend Framework是一个非常灵活的框架,几乎什么都可以扩展和自定义,框架是通用的,没自定义的好用。现在我要让他使用我自定义的Frontcontroller。
在application.ini中添加代码:pluginpaths.Flora_Application_Resource = Flora/Application/Resource
在library/Flora/Application/Resource/下新建Frontcontroller.php:
<?php /** * @see Flora_Controller_Front */ require_once 'Flora/Controller/Front.php'; /** * Flora_Application_Resource_Frontcontroller * * @author reallypride */ class Flora_Application_Resource_Frontcontroller extends Zend_Application_Resource_Frontcontroller { /** * Retrieve front controller instance * * @return Zend_Controller_Front */ public function getFrontController() { if (null === $this->_front) { $this->_front = Flora_Controller_Front::getInstance(); } return $this->_front; } } ?>
在library/Flora/Controller/下新建Front.php:
<?php /** * Flora_Controller_Front * * @author reallypride */ class Flora_Controller_Front extends Zend_Controller_Front { protected function __construct() { parent::__construct(); echo 'Flora_Controller_Front'; } /** * Singleton instance * * @return Zend_Controller_Front */ public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; } } ?> 运行程序检验一下,有没有成功啊?哈,自定义Zend Framework就是这么简单。