views:

649

answers:

2

I'm getting the following error when trying to use a modular layout in my Zend Framework application:

Undefined index: authentication in C:\PHP\includes\Zend\Controller\Dispatcher\Standard.php on line 385

The following code runs before this error:

if (!$this->_acl->isAllowed($role, $resource, $privilege)) {
 $request->setModuleName('authentication');
 $request->setControllerName('auth');
 $request->setActionName('login');
 $request->setDispatched(false);
}

in my bootstrap, I have:

$frontController
 ->setParam('environment', $this->environment)
 ->setControllerDirectory(ROOT_DIR . '/controllers')
 ->addModuleDirectory(ROOT_DIR . '/modules');

and my directory structure is:

/ application
    / controllers
    / models
    / views
    / library
    / modules
        / Authentication
            / controllers
                AuthController.php

Any thoughts why that's not working?

+1  A: 

Case sensitivity? There's nothing I found in the docs that specifically mentions case sensitivity, but all the examples with modules also show module directory names that are all lowercase.

My own, recent ZF app uses modules and the directory names are all lowercase.

Also, do you have a default module set in your route definitions?

Peter Bailey
Thanks Peter, that certainly got rid of that error message. Unfortuntely, another appeared in it's place:PHP Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller class ("Authentication_AuthController")' in C:\PHP\includes\Zend\Controller\Dispatcher\Standard.php:353I haven't defined a default module - I thought I could just keep my app-specific files directly under the application directory - is this not the case? (i see that my directory structure above was wrong - I've now made all folders children of application).
Iain
Ok - the error message was because I need to then name my controller class with a Module_Controller convention, as opposed to just Controller, right? So Authentication_AuthController instead of just AuthController.
Iain
That is correct - the controller names need to be prepended with the module name.
Peter Bailey
A: 

Out of curiosity, why do you have an entire module set up for authentication (as opposed to just having an action inside the default module take care of this)?

gaoshan88
Hi, I have authentication as a module because i felt it was application-generic functionality - if it's a module, I can then drop that module into any application. 'Authentication' might be misleading, as I expect to include login, logout, password retrieval, and profile management. How would you do it?
Iain