[置顶] ZF框架学习笔记

来源:互联网 发布:华为编程大赛题目 编辑:程序博客网 时间:2024/05/20 09:24
1. 环境设置define('APPLICATION_PATH','../application');define('LANGUAGE_PATH','../language');define('BASE_PATH',dirname(__FILE__));error_reporting(E_ALL|E_STRICT);ini_set('display_errors', 1);date_default_timezone_set('Asia/Chongqing');// 目录设置和类装载set_include_path('.' . PATH_SEPARATOR . '../library/'. PATH_SEPARATOR . '../include/'    . PATH_SEPARATOR . '../application/models/'    . PATH_SEPARATOR . '../application/controllers/'    . PATH_SEPARATOR . '../application/administrator/models/'    . PATH_SEPARATOR . '../application/administrator/controllers/'    . PATH_SEPARATOR . get_include_path());require_once 'Zend/Loader/Autoloader.php';2. Zend_Registry -- 全局对象注册表get / set / getInstance / setInstance / isRegistered3. Zend_Loader -- 代码组织1. Zend_Loader_Autoloader --  it registers itself with spl_autoload原理: 通过 spl_autoload_register 进行注册code:$loader = Zend_Loader_Autoloader::getInstance();$loader->setFallbackAutoloader(true);$loader->suppressNotFoundWarnings(false);$loader->registerNamespace('App_');方法:registerNamespace(string $ns) :if your library code is prefixed with "App_", you could do so as follows: $loader->registerNamespace('App_');suppressNotFoundWarnings(bool) 是否压制错误警告信息setFallbackAutoloader(bool)  4. Zend_Config -- 简化访问和使用配置数据1. Zend_Config 向构造器中传入数组2. Zend_Config_Ini 3. Zend_Config_Xml5. Zend_Db