Zend Framework Layout

后端 未结 3 752
轻奢々
轻奢々 2021-02-01 08:56

I\'m beginning with Zend Framework and I would like to understand Bootstrap file. I\'ve learned all _init methods are executed by default but it seems confusing to

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-01 09:08

    refer to this documentation for available options.

    Zend_Application will automatically bootstrap anything in the application.ini which begins with resources.

    Note that if you do not put something in your ini file, it will not be loaded. E.g. by default no layout is loaded. If you include either one, or both, of the following the layout will be enabled for the application:

    resources.layout.layoutPath = APPLICATION_PATH "/layouts"
    resources.layout.layout = default
    

    Most important to realise is that it will load the defaults where you have omitted values, let me explain: By default the bootstrap won't have a view resource available, because none is set in the ini. But if you put this in the ini:

    resources.view[] =
    

    then you can call:

    $this->boostrap('view');
    $view = $this->boostrap()->getResource('view');
    

    Then you can do something with your app's view from the bootstrap, e.g.

    $view->doctype("HTML5");
    

    Also, your _initAutoload is not necessary anymore, and can be replaced with

    appnamespace = ""
    

    in the .ini. I concur that the bootstrapping and ini options are very poorly documented.

    ////////////////////////////////////////////////////////////////////////////////

    else for hands-on learning:

    protected function _initIniDump()
    {
        $ini = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', 'development');
        Zend_Debug::dump($ini->toArray(), 'APPLICATION.INI');die();
    }
    

    In that dump you will see that Zend will iterate over the resources array, anything that it recognizes, it loads to best of it's knowledge

    :)

    Hope that helps.

提交回复
热议问题