phpzend-frameworkzend-db

What is the use of bootstrap and ini files and give me some exp?


I am new to zend framework I would like to know about bootstrap.php and .ini files and can you explain me with one example?

with database example also ..


Solution

  • Apart from official ZF quick start, I could recomend you to have a look at Tutorial: Getting Started with Zend Framework 1.10. You could also check out free book: Zend Framework Book: Surviving The Deep End and ZendCast.

    Edit. By request of the OP in the comments below, I paste some example of Bootstrap.php and an ini file:

    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/