模块引导错误

时间:2011-07-24 11:22:11

标签: zend-framework bootstrapping zend-view

我的application.ini

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"

bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
test.bootstrap.path = APPLICATION_PATH "/modules/test/Bootstrap.php"
test.bootstrap.class = "Test_Bootstrap"

appnamespace = "Application"

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"

resources.view.basePath = APPLICATION_PATH "/views/"

resources.view[] =
test.resources.view[] = 

db.adapter = "PDO_MYSQL"
db.params.dbname = "money"
db.params.username = "root"
db.params.password = "**************"

resources.modules[] =
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

应用/模块/测试/ bootstrap.php中

class Test_Bootstrap extends Zend_Application_Module_Bootstrap
{
    protected function _initLeftMenu()
    {
        $this->bootstrap('View');
        $view = $this->getResource('View');
        $view->render('index/_left_menu.phtml'); // <-- here error
    }
}

$view->render

有问题
  

致命错误:未捕获的异常'Zend_View_Exception',消息为'no   查看脚本目录集;无法确定查看位置   脚本'在C:\ ZendFramework \ library \ Zend \ View \ Abstract.php:973 Stack   trace:#0 C:\ ZendFramework \ library \ Zend \ View \ Abstract.php(884):   Zend_View_Abstract-&gt; _script('_ left_menu.phtm ...')#1   E:\ WWW \ money2 \应用\模块\测试\ bootstrap.php中(19):   Zend_View_Abstract-&gt; render('_ left_menu.phtm ...')#2   C:\ ZendFramework \库\ Zend的\应用程序\引导\ BootstrapAbstract.php(667):   Test_Bootstrap-&gt; _initLeftMenu()#3   C:\ ZendFramework \库\ Zend的\应用程序\引导\ BootstrapAbstract.php(620):   Zend_Application_Bootstrap_BootstrapAbstract-&gt; _executeResource('leftmenu')#4   C:\ ZendFramework \库\ Zend的\应用程序\引导\ BootstrapAbstract.php(584):   Zend_Application_Bootstrap_BootstrapAbstract-&gt; _bootstrap(NULL)#5   C:\ ZendFramework \库\ Zend的\应用\资源\ Modules.php(124):   Zend_Application_Bootstrap_BootstrapAbstract-&gt; bootstrap()#6   C:\ ZendFramework \ library \ Zend \ Application \ Resource \ Mod in   第973行的C:\ ZendFramework \ library \ Zend \ View \ Abstract.php

任何想法?

2 个答案:

答案 0 :(得分:0)

删除test.resources.view[] =

查看模块中的资源替换主引导程序中的视图。

提示:
模块引导程序中的$this->getApplication();将返回主引导程序
用它来引导和检索视图。

class Test_Bootstrap extends Zend_Application_Module_Bootstrap
{
    protected function _initLeftMenu()
    {
        //main bootstrap, injected by modules resource
        $bootstrap = $this->getApplication();
        $bootstrap->bootstrap('View');
        $view = $bootstrap->getResource('View');
        $view->render('index/_left_menu.phtml'); // <-- here error
    }
}
顺便说一下,bootstrap不是渲染东西的好地方。考虑将其移至更合适的地方。例如动作助手。
另请检查this blog post

答案 1 :(得分:0)

找到自己的救赎: 的application.ini

test.resources.view.basePath = APPLICATION_PATH "/modules/test/views/"