模块引导错误

发布于 2024-11-25 14:03:57 字数 2696 浏览 3 评论 0原文

我的 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

application/modules/test/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 中的脚本' 跟踪:#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 中 C:\ZendFramework\library\Zend\View\Abstract.php 第 973 行

有什么想法吗?

my 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

application/modules/test/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
    }
}

have a problem with $view->render

Fatal error: Uncaught exception 'Zend_View_Exception' with message 'no
view script directory set; unable to determine location for view
script' in C:\ZendFramework\library\Zend\View\Abstract.php:973 Stack
trace: #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 on line 973

any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无人问我粥可暖 2024-12-02 14:03:57

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

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

find own salvation:
application.ini

test.resources.view.basePath = APPLICATION_PATH "/modules/test/views/"
回眸一遍 2024-12-02 14:03:57

删除 test.resources.view[] =

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

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

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
    }
}

顺便说一句,引导程序不是渲染某些内容的好地方。考虑将其移动到更合适的地方。例如动作助手。
另请查看这篇博文

remove test.resources.view[] =

View resource in module replaces view from main bootstrap.

Hint:
$this->getApplication(); in module bootstrap will return main bootstrap
Use it to bootstrap and retrieve view.

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
    }
}

btw, bootstrap isn't a good place to render something. Consider moving it to more appropriate places. Action helper for example.
Also check this blog post

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文