开发者

Zend Framework -- Simple bootstrap edit causing application to fail

I'm working throug开发者_如何学Ch the Zend Framework 1.8 Web Development book, and I'm at the part that describes how you can edit the bootstrap.php to initialize a doctype for you. However, when I insert the function, I get a server error when I navigate to my project.

The application only breaks after I add the following code to my Bootstrap.php

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

    protected function _initViewSettings()
    {
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
    }

}


Matthew's article on this topic made things very clear for me:

http://weierophinney.net/matthew/archives/230-Quick-Start-to-Zend_Application_Bootstrap.html

I recommend reading the whole article as well as the linked manual page:

http://framework.zend.com/manual/en/zend.application.available-resources.html

So if you are initializing the view, you could do something like this:

protected function _initView()
{
    $view = new Zend_View();
    $view->doctype('XHTML1_STRICT');
    // do other stuff to the view...
    return $view;
}

What the others are saying is correct. However, I found the methods described by Matthew and using the application.ini as well to provide the cleanest bootstrap. Please do read the article as it explains dependencies and naming conventions.

It also seems like you do not have your error reporting settings configured to display detailed errors. If you change this, you will see a more concise error, rather than just the general HTTP 500.


Make sure you have the view resource in your config. Otherwise, there will be no view resource. It's also good to set the view encoding so kill two birds with one stone

resources.view.encoding = "UTF-8"

I have the following in my Bootstrap.php file (ZF 1.11.4) and it works just fine

protected function _initDoctype()
{
    $this->bootstrap('view');

    /* @var $view Zend_View */
    $view = $this->getResource('view');

    $view->doctype(Zend_View_Helper_Doctype::HTML5);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜