更改 Zend Framework 默认模块

发布于 2024-12-29 03:29:40 字数 1700 浏览 0 评论 0原文

我正在开发一个项目,并具有以下项目布局:

|Project
    |-Application
        |-api
        |-configs
        |-controllers
        |-models
        |-modules
            |-core
                |-controllers
                |-models
                |-views
                |-Bootstrap.php
            |-site1
            |-site2
            |-site3
        |-views
        |-Bootstrap.php
    |-Docs
    |-Library
    |-Public
    |-.zfproject.xml

我在 application.ini 中使用了它来尝试将 default 模块设置为 core 模块:

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

resources.frontController.defaultModule = "core"
resources.frontController.defaultControllerName = "Index"
resources.frontController.defaultAction = "index"

resources.modules[] = ""

我的问题是,由于某种原因,我无法让引导程序在模块中工作。就好像默认模块没有被更改一样。应用程序的行为就像它一样,直到我尝试加载引导程序 - 我收到此错误:

致命错误:未捕获的异常“Zend_Application_Resource_Exception” 带有消息“找到模块“默认”的引导文件,但引导程序 未找到“Default_Bootstrap”类 M:\Zend_Framework\library\Zend\Application\Resource\Modules.php 上 第85行

以此错误为前缀:

Zend_Application_Resource_Exception:找到模块的引导文件 “default”但未找到引导类“Default_Bootstrap” M:\Zend_Framework\library\Zend\Application\Resource\Modules.php 上 第85行

有人能看出我哪里出错了吗?

我的应用程序/Bootstrap.php 文件:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
}

我的应用程序/Core/Bootstrap.php 文件:

class Core_Bootstrap extends Zend_Application_Module_Bootstrap 
{   
}

I'm working on a project and have the following project layout:

|Project
    |-Application
        |-api
        |-configs
        |-controllers
        |-models
        |-modules
            |-core
                |-controllers
                |-models
                |-views
                |-Bootstrap.php
            |-site1
            |-site2
            |-site3
        |-views
        |-Bootstrap.php
    |-Docs
    |-Library
    |-Public
    |-.zfproject.xml

I've used this in my application.ini to try and set the default module to be the core module:

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

resources.frontController.defaultModule = "core"
resources.frontController.defaultControllerName = "Index"
resources.frontController.defaultAction = "index"

resources.modules[] = ""

My problem is that for some reason, I can't get bootstraps working in the modules. It's alsmost as if the default module isn't being changed. The application behaves like it is, until I try and load the bootstraps - I get this error:

Fatal error: Uncaught exception 'Zend_Application_Resource_Exception'
with message 'Bootstrap file found for module "default" but bootstrap
class "Default_Bootstrap" not found' in
M:\Zend_Framework\library\Zend\Application\Resource\Modules.php on
line 85

Prefixed by this error:

Zend_Application_Resource_Exception: Bootstrap file found for module
"default" but bootstrap class "Default_Bootstrap" not found in
M:\Zend_Framework\library\Zend\Application\Resource\Modules.php on
line 85

Can anyone see where I'm going wrong?

My Application/Bootstrap.php file:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
}

My Application/Core/Bootstrap.php file:

class Core_Bootstrap extends Zend_Application_Module_Bootstrap 
{   
}

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

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

发布评论

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

评论(2

金兰素衣 2025-01-05 03:29:40

不是 100%,但如果删除以下行:

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"

可能会解决问题。如果我没记错的话,当您使用模块时,设置它会导致错误。

Not 100% on this but if you remove the following line:

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"

that may resolve the issue. If i'm not mistaken, as you're using modules, setting this will cause an error.

空气里的味道 2025-01-05 03:29:40

看起来您的 application.ini 中可能缺少一行:

resources.frontController.params.prefixDefaultModule = ""

尝试以这种方式使用它并查看它是否有效,我认为这只是告诉应用程序在使用模块时,名为 'default'< 的模块/em> 没有前缀。
虽然我可能是错的,所以你可能必须尝试一下。
好吧,也许少了两行:)

resources.frontController.moduleControllerDirectoryName = "controllers"

Looks like you might be missing one line from your application.ini:

resources.frontController.params.prefixDefaultModule = ""

Try using it this way and see if it works, I think this just tells the app that when using modules, the module named 'default' has no prefix.
Although I could be wrong so you may have to experiment.
Ok, maybe two lines are missing :)

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