bootstrap和ini文件的用途是什么,给我一些exp?

时间:2011-02-23 07:59:56

标签: php zend-framework zend-db

我是zend框架的新手我想知道bootstrap.php和.ini文件,你可以用一个例子来解释我吗?

还有数据库示例..

1 个答案:

答案 0 :(得分:1)

除官方ZF quick start外,我建议您查看Tutorial: Getting Started with Zend Framework 1.10。您还可以查看免费图书:Zend Framework Book: Surviving The Deep EndZendCast

编辑。根据下面评论中的OP请求,我粘贴了一些Bootstrap.php和一个ini文件的例子:

<强> bootstrap.php中

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {

    // set a doctype for the Zend_View    
    protected function _initDoctype() {
        $view = $this->bootstrap('view')->getResource('view');
        $view->doctype('XHTML1_STRICT');
    }

    // add path to my view helpers
    protected function _initHelperPath() {
        $view = $this->bootstrap('view')->getResource('view');
        $view->setHelperPath(APPLICATION_PATH . '/views/helpers', 'My_View_Helper');
    }

    // read appkey.ini and save it to registry for later use
    protected function _initAppKeysToRegistry() {

        $appkeys = new Zend_Config_Ini(APPLICATION_PATH . '/configs/appkeys.ini');
        Zend_Registry::set('keys', $appkeys);
    }

}

<强> appkeys.ini

; facebook and twitter app keys obtained after registering your app
; with these two websites.  

facebook.appid = YOUR_FACEBOOK_APPID
facebook.secret = YOUR_FACEBOOK_SECRET
facebook.redirecturi = http://url.of.your.app/
facebook.scope = 'email'

twitter.appid = YOUR_TWITTER_APPID
twitter.secret = YOUR_TWITTER_SECRET
twitter.redirecturi = http://url.of.your.app/