【问题标题】:Zend Framework modules not workingZend 框架模块不工作
【发布时间】:2011-05-23 15:18:45
【问题描述】:

嗨 我无法让我的 Zend Framework 应用程序使用模块。基本上我有两个名为“默认”的模块(是的,这是我的默认模块)和“面板”。我想在这个请求下调用一个登录控制器:

mywebsite.host/panel/login/index

因此它应该让我登录控制器位于:/panel/controllers/LoginController.php LoginController.php 的类是 panel_LoginController。

这是我在 Standard.php 中的调试代码 ->

public function isDispatchable(Zend_Controller_Request_Abstract $request)
{
    $className = $this->getControllerClass($request);
    echo '<pre>'; print_r($request); echo '</pre>';
    if (!$className) {
        return false;
    }

    if (class_exists($className, false)) {
        return true;
    }

    $fileSpec    = $this->classToFilename($className);
    $dispatchDir = $this->getDispatchDirectory();
    $test        = $dispatchDir . DIRECTORY_SEPARATOR . $fileSpec;
    echo '<pre>'; print_r($test .'|'.$fileSpec); echo '</pre>';
    return Zend_Loader::isReadable($test);
}

我得到了这个:

Zend_Controller_Request_Http Object
(
    [_paramSources:protected] => Array
        (
            [0] => _GET
            [1] => _POST
        )

    [_requestUri:protected] => /
    [_baseUrl:protected] => 
    [_basePath:protected] => 
    [_pathInfo:protected] => /
    [_params:protected] => Array
        (
            [controller] => index
            [action] => index
            [module] => default
        )

    [_rawBody:protected] => 
    [_aliases:protected] => Array
        (
        )

    [_dispatched:protected] => 1
    [_module:protected] => default
    [_moduleKey:protected] => module
    [_controller:protected] => index
    [_controllerKey:protected] => controller
    [_action:protected] => index
    [_actionKey:protected] => action
)

还有:

/application/default/controllers/IndexController.php|IndexController.php

它应该在哪里: /application/panel/controllers/IndexController.php|IndexController.php

我的 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"
;resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
;resources.frontController.moduleDirectory = APPLICATION_PATH
resources.layout.layoutpath  = APPLICATION_PATH "/layouts"
resources.layout.layout = default

resources.frontController.modules = true
;resources.frontController.controllerDirectory = APPLICATION_PATH "/default/controllers"
resources.frontController.moduleControllerDirectoryName = "controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH ""
resources.frontController.defaultControllerName = "index"
resources.frontController.defaultAction = "index"
resources.frontController.defaultModule = "default"
resources.frontController.params.prefixDefaultModule = "1"

cache.frontend = Core
cache.backend = File
cache.frontendOptions.automatic_serialization = true
cache.backendOptions.cache_dir = APPLICATION_PATH "/../temp"

知道我做错了什么吗?当然,如果我将 Standard.php 返回到原生 Zend 库状态,则会出现无法找到控制器的致命错误。

【问题讨论】:

    标签: php zend-framework


    【解决方案1】:

    将应用程序目录作为模块目录并不是一个好主意。这将导致将所有子文件夹注册为模块。

    类名应该是 Panel_LoginController

    【讨论】:

      【解决方案2】:

      试试这个 - 放入你的 application.ini:

      resources.modules[] = ""
      resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
      

      然后在应用程序中创建“模块”文件夹。每个模块都应该有 Bootstrap.php 文件:

      class Somemodule_Bootstrap extends Zend_Application_Module_Bootstrap {}

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-19
        • 2012-04-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多