您好 我无法使我的Zend Framework应用程序使用模块。基本上我有两个名为'default'的模块(是的,它是我的默认模块)和'panel'。我想根据此请求调用Login控制器:
mywebsite.host/panel/login/index
因此它应该得到我的LoginController:/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库状态,我发现致命错误,无法找到控制器。
答案 0 :(得分:1)
将应用程序目录作为模块目录不是一个好主意。这将导致将所有子文件夹注册为模块。
classname应该是Panel_LoginController
答案 1 :(得分:0)
试试这个 - 放入你的application.ini:
resources.modules[] = ""
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
然后在Application中创建“modules”文件夹。每个模块都应该包含Bootstrap.php文件:
class Somemodule_Bootstrap extends Zend_Application_Module_Bootstrap {}