2009-04-09 8 views
0

Je suis en train de rendre mon fichier bootstrap.php plus organisé, mais après avoir tout mis dans des méthodes statiques séparées, je ne peux charger aucune page au-delà du contrôleur d'index. Par exemple. si je tente d'ouvrirErreur "Aucun module par défaut défini" dans l'application Zend Framework

http://localhost/zftutorial/login/index

Je reçois

Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 
'Invalid controller class ("Login_IndexController")' in C:\Program 
Files\VertrigoServ\www\library\Zend\library\Zend\Controller\Dispatcher\Standard.php:341 
Stack trace: #0 C:\Program 
Files\VertrigoServ\www\library\Zend\library\Zend\Controller\Dispatcher\Standard.php(255): 
Zend_Controller_Dispatcher_Standard->loadClass('IndexController') #1 C:\Program 
Files\VertrigoServ\www\library\Zend\library\Zend\Controller\Front.php(934): 
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), 
Object(Zend_Controller_Response_Http)) #2 C:\Program 
Files\VertrigoServ\www\zftutorial\public\index.php(18): Zend_Controller_Front->dispatch() 
#3 C:\Program Files\VertrigoServ\www\zftutorial\public\index.php(138): Bootstrap::run() #4 
{main} thrown in C:\Program 
Files\VertrigoServ\www\library\Zend\library\Zend\Controller\Dispatcher\Standard.php on 
line 341 

et dans mon dossier bootstrap me semble avoir défini où les contrôleurs chould être trouvés:

public static function setupFrontController() 
{ 
    self::$frontController = Zend_Controller_Front::getInstance(); 
    self::$frontController->throwExceptions(true); 
    self::$frontController->returnResponse(true); 
    self::$frontController->setBaseUrl('/zftutorial'); 

    self::$frontController->setControllerDirectory(
     array(
      'default' => self::$root . '../application/controllers', 
      'admin' => self::$root . '../application/controllers', 
      'index' => self::$root . '../application/controllers', 
      'login' => self::$root . '../application/controllers', 
      'user' => self::$root . '../application/controllers' 
     ) 
    ); 

    self::$frontController->setParam('registry', self::$registry); 

} 

Peut-être a pour faire quelque chose avec le routage, mais mon application a bien fonctionné avec le routage implicite avant, par exemple d'autres contrôleurs ont bien fonctionné aussi. Quelle est la source de l'erreur ci-dessus? Comment puis-je le tester/le trouver/le réparer?

Répondre

0

En regardant votre pile trace l'erreur est classe contrôleur non valide (« Login_IndexController »)

Ceci suggère que la Login_IndexController de classe n'existe pas.

Vous devriez avoir un fichier appelé IndexController.php dans le répertoire du contrôleur du module de connexion. La structure que vous avez actuellement ne fonctionnera pas car deux modules ne peuvent pas avoir un contrôleur avec le même nom. Changez la structure en

self::$frontController->setControllerDirectory(
     array(
      'default' => self::$root . '../application/modules/default/controllers', 
      'admin' => self::$root . '../application/modules/admin/controllers', 
      'index' => self::$root . '../application/modules/index/controllers', 
      'login' => self::$root . '../application/modules/login/controllers', 
      'user' => self::$root . '../application/modules/user/controllers' 
     ) 
    ); 

Créez le IndexController.php dans self :: $ root. '../application/modules/login/controllers et assurez-vous que la classe est appelée Login_IndexController