本文实例讲述了Zend Framework教程之Application用法。分享给大家供大家参考,具体如下:
Zend_Application是Zend Framework的核心组件。Zend_Application为Zend Framework应用程序提供基本功能,是程序的入口点。它的主要功能有两个:装载配置PHP环境(包括自动加载),并引导应用程序。
通常情况下,通过配置选项配置Zend_Application构造器,但也可以完全使用自定义方法配置。以下是两个使用用例。
Zend_Application配置选项
构造函数:
/** * Constructor * * Initialize application. Potentially initializes include_paths, PHP * settings, and bootstrap class. * * @param string $environment * @param string|array|Zend_Config $options String path to configuration file, or array/Zend_Config of configuration options * @throws Zend_Application_Exception When invalid options are provided * @return void */public function __construct($environment, $options = null){ $this->_environment = (string) $environment; require_once 'Zend/Loader/Autoloader.php'; $this->_autoloader = Zend_Loader_Autoloader::getInstance(); if (null !== $options) { if (is_string($options)) { $options = $this->_loadConfig($options); } elseif ($options instanceof Zend_Config) { $options = $options->toArray(); } elseif (!is_array($options)) { throw new Zend_Application_Exception('Invalid options provided; must be location of config file, a config object, or an array'); } $this->setOptions($options); }}
Zend_Application配置方法
1.使用配置文件
2.使用配置数组
常见配置选项
Option | Description |
---|---|
phpSettings | 用于配置php.ini选项,要求是数组,数组的键应该是选项的的key. |
includePaths | 把附加的路径加入到include_path,要求是数组 |
autoloaderNamespaces | 给Zend_Loader_Autoloader注册附加命名空间,为数组 |
bootstrap | 可以是设置bootstrap引导类的路径的字符串,也可以是数组,数组元素要求为 'path' 和 'class' |
新闻热点
疑难解答