Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [ZF] Problem z routingiem
Forum PHP.pl > Forum > PHP > Frameworki
orideith
Witam mam taki problem z ZF chciałem ustawić 2 moduły jeden admin drugi domyślny, w którym miała by być strona docelowa ale niestety to niedziała.

Bootstrap wygląda tak (wycinek)

  1. <?php
  2. $base = '/';
  3. $frontController = Zend_Controller_Front::getInstance();
  4. $frontController->setBaseUrl($base);
  5. $frontController->throwExceptions(true);
  6. $frontController->setControllerDirectory(
  7. array('default' => './application/default/controllers','admin'=> './application/admin/controllers')
  8. );
  9. $route = new Zend_Controller_Router_Route( ':module/:controller/:action/*', array('module' => 'default', 'controller' => 'index', 'action' => 'index'));
  10. $route_admin = new Zend_Controller_Router_Route( ':module/:controller/:action/*', array('module' => 'admin', 'controller' => 'admin', 'action' => 'index'));
  11. $router = $frontController->getRouter();
  12. $router->addRoute('default', $route);
  13. $router->addRoute('admin', $route_admin);
  14. $frontController->setRouter($router);
  15.  
  16. // run!
  17. $frontController->dispatch();
  18. ?>


i tak jeżeli odpale http://localhost/default/index/index to odpala mi sie IndexController z katalogu /application/default/controllers/IndexController.php i tu jest ok zgodnie z opisem na http://framework.zend.com/manual/en/zend.c...routes.standard głównie punkt 7.5.4 tak jak jest opisane

ale jak chce odpalić http://localhost/admin/admin/index (gdzie jest /application/admin/controllers/AdminController.php) to dostaje błąd typu
  1. <?php
  2. Zend_Controller_Dispatcher_Exception: Invalid controller class ("Admin_AdminController") in G:wwwDentistica_cmslibraryZendControllerDispatcherStandard.php on line 353
  3.  
  4. [tak to z Xdebug wyglada]
  5.  
  6. $file = string 'AdminController.php' (length=19)
  7. $loadFile = string './application/admin/controllersAdminController.php' (length=51)
  8. $finalClass = string 'Admin_AdminController' (length=21)
  9. $dispatchDir = string './application/admin/controllers' (length=31)
  10. $className = string 'AdminController' (length=15)
  11. $dir = string './application/admin/controllers' (length=31)
  12. ?>


I teraz pytanie co jest nie tak próbowałem na wiele sposobów ale nie wiem czemu nie działa.

Będę wdzięczny za podpowiedź podejrzewam, że nie wiele trzeba tu zmienić ale nie wiem gdzie dokładnie
nevt
prosze zmienić tagi bbcode z [code] na [php] - w obecnej postaci kod jest zupełnie nieczytelny
cckoles
wystarczy abys ustawil front controler w ten sposob i będzie działać


  1. <?php
  2. // ustawienie kontrolera
  3. $frontController = Zend_Controller_Front::getInstance();
  4. $frontController->throwExceptions(true);
  5. $frontController->setControllerDirectory(array(
  6. 'default' => '../application/modules/default/controllers',
  7. 'admin'  => '../application/modules/admin/controllers'));
  8.  
  9. // run!
  10. $frontController->dispatch();
  11. ?>


pozniej wywolujesz dany modul tak jak napisales ale w samym kontrolerze admin musisz wstawiac prefix do nazyw klasy kontrolera Admin_NazwaKontrolera
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.