【问题标题】:What is the use of bootstrap and ini files and give me some exp?bootstrap和ini文件有什么用,给我一些exp?
【发布时间】:2011-02-23 07:59:55
【问题描述】:

我是 zend 框架的新手,我想了解 bootstrap.php 和 .ini 文件,你能举个例子解释一下吗?

还有数据库示例..

【问题讨论】:

    标签: php zend-framework zend-db


    【解决方案1】:

    除了官方ZF quick start,我还可以推荐你看看Tutorial: Getting Started with Zend Framework 1.10。您还可以查看免费书籍:Zend Framework Book: Surviving The Deep EndZendCast

    编辑。应下面 cmets 中 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/
    

    【讨论】:

    • 我研究了那个,我在示例中创建了一个没有任何引导和 ini 文件的登录表单...那么为什么我们需要这些文件并给我一个示例?
    • @kiran。你研究过哪个没有Bootsrap.php和ini文件的?
    • 是的,我们有,但问题是我们为什么要在没有该文件的情况下使用该文件,而且我们的示例正在运行..
    • @kiran。 ini 和 bootstrap 文件用于配置和启动 zF 资源。您不需要使用它们,但是如果您例如为您的应用程序设置区域设置,您可以在您的 ini 或引导程序中进行。否则,ZF 将仅使用默认值或资源,这可能并不适合所有人。
    • @Marcin..你能有一个包含 bootstrap.php 和 .ini 文件的示例吗?
    猜你喜欢
    • 2012-11-19
    • 2016-01-03
    • 2011-02-13
    • 2012-06-07
    • 2020-10-07
    • 2012-11-03
    • 2014-01-07
    • 2019-11-28
    • 1970-01-01
    相关资源
    最近更新 更多