views:

1216

answers:

1

Hi everyone,

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 me. Anyway that is not what I would like to ask.

A came around the $this->bootstrap('layout'); action and I'm not sure if I understand this. Is this the resource.layout variable in application.ini file? I would like to really understand the bootstrap process in deep.

I'm asking you for step by step explanation. Thanks in advance!

So this is my bootstrap file:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initAutoload()
    {
        $moduleLoader = new Zend_Application_Module_Autoloader(array(
            'namespace' => '',
         'basePath' => APPLICATION_PATH
        ));
        return $moduleLoader;
    }

    function _initViewHelpers()
    {
        $this->bootstrap('layout');

        $layout = $this->getResource('layout');
        $view = $layout->getView();
        $view->doctype('XHTML1_STRICT');
        $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
        $view->headTitle()->setSeparator(' - ');
        $view->headTitle('Zend Framework Tutorial');
    }
}
+1  A: 

Hello,

I have found out that: calling $this->boostrap('resource'); will not work if 'resource' is not in the application/configs/application.ini file. So my answer to your question would be 'yes', you have to define the layout resource in the application.ini file with the following : resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts" (or another dir.)

Unfortunately the zend Framework documentation is really bad in my opinion. Especially on this topic.

My opinion is that you should wait for a version with a better documentation if you want to get deep into the details and workings of the Zend Framework (or you can check the source code of the Zend Library Classes if you have the time).

andreas
Yes, in this case is the ZF manual just loads of crap and no examples. Really bad. I hope that there will be some tutorials soon / or better manual.
Tomáš Fejfar
The ZF manual is a bit lame at times and sort of like a wiki/tutorial. However, if you keep reading and keep programming stuff with ZF, eventually you understand all the parts you work with - at least that is how it was for me. The docs cover most things, but they are scattered here and there. So it does take lots of exposure and fiddling to get a deeper understanding of what is happening. Good luck!
sims