Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZendFramework] Podział na moduły, Invalid controller
Siner
post
Post #1





Grupa: Zarejestrowani
Postów: 159
Pomógł: 6
Dołączył: 2.01.2004

Ostrzeżenie: (0%)
-----


Aplikację podzieliłem w taki sposób.

Dla modułu defaults wszystko działa ok, natomiast gdy wywołuje moduł admin dostaję błąd.
"Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (index)' in Standard.php:241 Stack trace:
#0 Zend/Controller/Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 /public/index.php(43): Zend_Controller_Front->dispatch()
#2 {main} thrown in Zend/Controller/Dispatcher/Standard.php on line 241"


bootstrap.php
  1. <?php
  2. $frontController = Zend_Controller_Front::getInstance();
  3. $frontController->throwExceptions(true);
  4. $frontController->setModuleControllerDirectoryName('controllers');
  5. $frontController->addModuleDirectory(APPLICATION_PATH . '/modules');
  6. ...
  7. $config = new Zend_Config_Ini(APPLICATION_PATH . '/config/routes.ini');
  8. $router = $frontController->getRouter();
  9. $router->addConfig($config, 'routes');
  10. $frontController->setRouter($router);
  11. ?>

/config/routes.ini
Kod
[routes]  
default.route                 = ":controller/:action/*"
default.defaults.module        = "default"
default.defaults.controller  = "index"
default.defaults.action         = "index"

admin.route            = "admin/:controller/:action/*"
admin.defaults.module     = "admin"
admin.defaults.controller  = "index"
admin.defaults.action      = "index"

Jeszcze mam pytanie, jak zrobić jeden katalog z modelami dla wszystkich modułów?


--------------------
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
batman
post
Post #2





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




Usuń z nazwy kontrolera admin_ i dodaj przed nazwę klasy, np admin_IndexController. Powinno zadziałać. Ścieżki też możesz sobie darować. A dlaczego chcesz zrobić jeden katalog na modele?


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post
Siner
post
Post #3





Grupa: Zarejestrowani
Postów: 159
Pomógł: 6
Dołączył: 2.01.2004

Ostrzeżenie: (0%)
-----


Racja, najgłupsze problemy są najtrudniejsze winksmiley.jpg
A modele chcę w jednym katalogu trzymać bo po co tworzyć dwa razy to samo. Jak np będę chciał pobrać listę użytkowników co jest możliwe np na stronie głownej jak i w panelu administracyjnym.

edit: poprawki składniowe winksmiley.jpg

Ten post edytował Siner 13.01.2009, 20:25:11


--------------------
Go to the top of the page
+Quote Post
batman
post
Post #4





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




Możesz to rozwiązać na dwa sposoby.
1. Obok katalogu Zend (w library), tworzysz swój katalog, np My lub App lub cokolwiek innego, a w nim katalog Module. W tym folderze przechowujesz modele "globalne".
2. Tworzysz klasę modelu tylko w admin i w innych modułach odwołujesz się do niej.


edit
Polecam rozwiązanie 2, ponieważ nie będziesz miał bałaganu w plikach.


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post
pejotr
post
Post #5





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 21.08.2007

Ostrzeżenie: (0%)
-----


ja korzystam z takiego rozwiązania, ani nie pisze 2 razy anie nie mam 1 katalogu na 2 moduły
http://phpimpact.wordpress.com/2008/08/12/...zend-framework/
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 00:02