【问题标题】:Error with module bootstrapping模块引导错误
【发布时间】:2011-10-11 23:56:45
【问题描述】:

我的应用程序.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-&gt;render 有问题

致命错误:未捕获的异常 'Zend_View_Exception' 带有消息 'no 查看脚本目录集;无法确定查看位置 脚本'在 C:\ZendFramework\library\Zend\View\Abstract.php:973 堆栈 跟踪:#0 C:\ZendFramework\library\Zend\View\Abstract.php(884): Zend_View_Abstract->_script('_left_menu.phtm...') #1 E:\www\money2\application\modules\test\Bootstrap.php(19): Zend_View_Abstract->render('_left_menu.phtm...') #2 C:\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(667): Test_Bootstrap->_initLeftMenu() #3 C:\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(620): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('leftmenu') #4 C:\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(584): Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap(NULL) #5 C:\ZendFramework\library\Zend\Application\Resource\Modules.php(124): Zend_Application_Bootstrap_BootstrapAbstract->bootstrap() #6 C:\ZendFramework\library\Zend\Application\Resource\Mod in C:\ZendFramework\library\Zend\View\Abstract.php 第 973 行

有什么想法吗?

【问题讨论】:

  • 为什么不用大写字符开始句子?
  • 稍后有人需要编辑此问题以满足 SO 标准。这是一个真实的人社区,其他人正在一遍又一遍地阅读您的帖子。您可以考虑一些额外的微型时间来正确编写问题,因为我们正在花时间找出您问题的答案。

标签: zend-framework bootstrapping zend-view


【解决方案1】:

删除test.resources.view[] =

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

提示:
模块引导程序中的$this-&gt;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
    }
}

顺便说一句,引导程序不是渲染某些东西的好地方。考虑将其移至更合适的位置。例如动作助手。
还要检查this blog post

【讨论】:

  • 今天晚上会试试你的推荐
  • 同样的问题。 没有查看脚本目录集;无法确定查看脚本的位置
  • @Subdigger 你如何检索你的视图实例?
【解决方案2】:

找到自己的救赎: 应用程序.ini

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

【讨论】:

  • 这暂时可行,但最终你会遇到麻烦。
  • @Xerkus 告诉我为什么?问题,正如我在上面所说的:没有查看脚本目录集。无论如何,我只桅杆设置目录。其他一切正常
  • 应用程序资源视图替换了 ViewRenderer 助手和视图实例。因此,当您在模块中使用它时,它会替换主引导程序中配置的视图实例。
猜你喜欢
  • 1970-01-01
  • 2019-05-25
  • 2015-09-29
  • 2017-01-15
  • 1970-01-01
  • 1970-01-01
  • 2019-05-27
  • 1970-01-01
  • 2012-07-14
相关资源
最近更新 更多