ZF-2429: Controller Module Bug


I use Controller Module: article, blog and so on. but no default module. because I don't want to use default controller.

when I request a url like '', I get some error messenge:

Notice: Undefined index: default in C:\web\zend\library\Zend\Controller\Dispatcher\Standard.php on line 330

I think that default module should be optional.


If you don't use a "default" module, then you should point to a module that is default for you (the one you're accessing by root '/') because that's how the framework works at the moment. For instance:


But after looking at the code, I guess Dispatcher would be a good candidate for refactoring. The method which throws an error does too much in my opinion. It's name and signature - getControllerClass(Zend_Controller_Request_Abstract $request) - suggests it returns controller class using Request object. But in fact, it does a lot more (and shouldn't). It could return a class name mid way and what follows should be refactored into more appropriate places.

This shouldn't be happening there:

        $controllerDirs      = $this->getControllerDirectory();
        $this->_curModule    = $this->_defaultModule;
        $this->_curDirectory = $controllerDirs[$this->_defaultModule];
        $module = $request->getModuleName();
        if ($this->isValidModule($module)) {
            $this->_curModule    = $module;
            $this->_curDirectory = $controllerDirs[$module];
        } else {

Matthew, I could give this class a revamp. Making sure it works as expected and passes all the unit tests. Everything I need is just a green light from you.

I have a question.

if I code: $dispatcher->setDefaultModule('blog');

then the controller name will be IndexController, not be Blog_IndexController

I think that above two names should be allowed for more consistency.

Duplicates ZF-1808.

Resolved in trunk. Passing the front controller or dispatcher parameter 'prefixDefaultModule' will ensure the controllers in the default module are namespaced.