Zend Framework modules not working
Hi I'm unable to make my Zend Framework application to use modules. Basicly I have two modules named 'default' (yes, it's my d开发者_Go百科efault module) and 'panel'. I want to call a Login controller under this request:
mywebsite.host/panel/login/index
thus it should get me LoginController under: /panel/controllers/LoginController.php the class of the LoginController.php is panel_LoginController.
Here is my debug code from the 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);
}
And I'm getting this:
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
)
And:
/application/default/controllers/IndexController.php|IndexController.php
Where it should be: /application/panel/controllers/IndexController.php|IndexController.php
My ini config file is somthing like this:
[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"
Any idea what I'm doing wrong? Of course if I return Standard.php to native Zend library state I've got fatal error that controller can't be found.
having application directory as module directory isn't a good idea. This will result in registering ALL subfolders as modules.
classname should be Panel_LoginController
Try this - put in your application.ini:
resources.modules[] = ""
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
and then create 'modules' folder in Application. Each module should have Bootstrap.php file with:
class Somemodule_Bootstrap extends Zend_Application_Module_Bootstrap {}
精彩评论