application.ini 非资源类的配置选项

这里主要说下文档里没有提到的非资源类选项,这要从代码入手。

public function setOptions

 函数是在实例化Zend_Application后,载入资源完毕后调用的。

从下面的代码不难看出,文档里没有提到的选项有下面几种

1.config

2.phpsettings

3.includepaths

4.autoloadernamespaces

5.autoloaderzfpath

6.bootstrap

至于各选项具体作用,没有在官方文档中查看过,只有自己看源码或百度或Google 去了

 

class Zend_Application {
//... 
public function setOptions(array $options)
    {
        if (!empty($options['config'])) {
            if (is_array($options['config'])) {
                $_options = array();
                foreach ($options['config'] as $tmp) {
                    $_options = $this->mergeOptions($_options, $this->_loadConfig($tmp));
                }
                $options = $this->mergeOptions($_options, $options);
            } else {
                $options = $this->mergeOptions($this->_loadConfig($options['config']), $options);
            }
        }

        $this->_options = $options;

        $options = array_change_key_case($options, CASE_LOWER);

        $this->_optionKeys = array_keys($options);

        if (!empty($options['phpsettings'])) {
            $this->setPhpSettings($options['phpsettings']);
        }

        if (!empty($options['includepaths'])) {
            $this->setIncludePaths($options['includepaths']);
        }

        if (!empty($options['autoloadernamespaces'])) {
            $this->setAutoloaderNamespaces($options['autoloadernamespaces']);
        }

        if (!empty($options['autoloaderzfpath'])) {
            $autoloader = $this->getAutoloader();
            if (method_exists($autoloader, 'setZfPath')) {
                $zfPath    = $options['autoloaderzfpath'];
                $zfVersion = !empty($options['autoloaderzfversion'])
                           ? $options['autoloaderzfversion']
                           : 'latest';
                $autoloader->setZfPath($zfPath, $zfVersion);
            }
        }

        if (!empty($options['bootstrap'])) {
            $bootstrap = $options['bootstrap'];

            if (is_string($bootstrap)) {
                $this->setBootstrap($bootstrap);
            } elseif (is_array($bootstrap)) {
                if (empty($bootstrap['path'])) {
                    throw new Zend_Application_Exception('No bootstrap path provided');
                }

                $path  = $bootstrap['path'];
                $class = null;

                if (!empty($bootstrap['class'])) {
                    $class = $bootstrap['class'];
                }

                $this->setBootstrap($path, $class);
            } else {
                throw new Zend_Application_Exception('Invalid bootstrap information provided');
            }
        }

        return $this;
    }
}
 

 

其它application.ini  的资源配置选项可参见

http://framework.zend.com/manual/en/zend.application.available-resources.html

中文样例可参见

http://hi.baidu.com/razr1/blog/item/0fd1cf27a72a17068b82a105.html,为方便,复制一份如下:

zend framework application.ini设置
2010-11-29 16:45
[production]

 
#PHP错误是否显示,您所在时区,bootstrap引导文件配置(1为true,0为false)
 
phpSettings.error_reporting = 8191
phpSettings.DATE.timezone   = "Asia/Shanghai"
phpSettings.display_startup_errors =1
phpSettings.display_errors = 1
bootstrap.path = APPLICATION_PATH "/Bootstrap.php" #后面会对这个引导文件做相应说明
bootstrap.class  = "Bootstrap" #这个名称请对应到上面Bootstrap.php文件中的类
 
 
#项目载入的模块,插件,错误提示信息配置
resources.FrontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.FrontController.moduleControllerDirectoryName = "controllers"
resources.FrontController.defaultModule = "default"
resources.FrontController.plugins.common = "Custom_Controller_Plugin_Layout"                              
resources.FrontController.noErrorHandler = 1
resources.FrontController.throwExceptions  = 1
#resources.FrontController.noViewRenderer=false
 
#网站页面标题,编码以及ViewHelper的设置(这些可有可无.我们可以在不同的模块中设置不同)
resources.view.title  = "Kylingood"
resources.view.encoding   = "UTF-8"
resources.view.helperPathPrefix = "Custom_View_Helper_"
resources.view.helperPath  = "Custom/View/Helper/"
 
#网站前台模块(不同模块对应不同layout,与不同的ViewHelper)
resources.view.params.DEFAULT.basePath = APPLICATION_PATH "/modules/default/views/"
resources.view.params.DEFAULT.helperPathPrefix  = "Custom_View_Helper_Default_"
resources.view.params.DEFAULT.helperPath  = "Custom/View/Helper/Default/"
resources.view.params.DEFAULT.layout  = "default"
resources.view.params.DEFAULT.layoutPath  = APPLICATION_PATH "/modules/default/views/layouts"
 
#用户后台模块(同上)
resources.view.params.user.basePath = APPLICATION_PATH "/modules/user/views/"
resources.view.params.user.helperPathPrefix  = "Custom_View_Helper_User_"
resources.view.params.user.helperPath  = "Custom/View/Helper/User/"
resources.view.params.user.layout  = "default"
resources.view.params.user.layoutPath  = APPLICATION_PATH "/modules/user/views/layouts"
 
#您数据库的配置参数
resources.db.adapter=PDO_MYSQL
resources.db.params.host ="localhost"
resources.db.params.username ="root"
resources.db.params.password ="uniono"
resources.db.params.dbname ="blog"
resources.db.params.prefix ="oophp_"
resources.db.isDefaultTableAdapter = TRUE
resources.db.params.driver_options.1002 = "SET NAMES UTF8;"
 
#网站多语言配置(前期学习可以不管,甚至于去掉)
resources.translate.registry_key = "Zend_Translate"
resources.translate.adapter = array
resources.translate.options.scan = "directory"
resources.translate.locale = "zh_CN"
resources.translate.data.zh_CN  = APPLICATION_PATH "/languages/zh_CN.php"
resources.translate.data.en_US  = APPLICATION_PATH "/languages/en_US.php"
 
#网站生成的日志(前期学习可以不管,甚至于去掉)
[logger]
priority = 7
file = "log/debug.txt"
;EMERG=0;ALERT=1;CRIT=2;ERR=3;WARN=4;NOTICE=5;INFO=6;DEBUG=7;
type = firebug
;stream,firebug
 
#网站生成Cache配置(前期学习可以不管,甚至于去掉)
[cache]
type = file
dir =APPLICATION_PATH"/cache/"
pagedir =APPLICATION_PATH"/cache/page/"
lifetime =7200
automatic_serialization = TRUE

转:http://www.oophp.cn/article/view/id/368
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值