2008年8月7日星期四

Re: [fw-mvc] Again... routing problem

-- Václav Vaník <vanik@walk.cz> wrote
(on Thursday, 07 August 2008, 08:50 AM -0700):
> Matthew Weier O'Phinney-3 wrote:
> > Do the files real/controllers/IndexController.php and
> > real/controllers/BooController.php define the classes
> > Real_IndexController and Real_BooController, respectively?
> >
> > Controllers in modules need to be prefixed with the module name (and the
> > module prefix is always passed to ucfirst()).
>
> oh, mistake...
>
> I renamed files, I have now:
>
> ROOT_DIR . '/app/www/modules/default/IndexController.php';
> ROOT_DIR . '/app/www/modules/default/FooController.php';
>
> ROOT_DIR . '/app/www/modules/real/Real_IndexController.php';
> ROOT_DIR . '/app/www/modules/real/Real_BooController.php';
>
> In the "real module files" I have classes:
>
> and which classes names are correct?
>
> a) IndexController and BooController
> b) RealIndexController and RealBooController
> c) Real_IndexController and Real_BooController

It's all wrong right now. Try this directory/class structure:

modules/
default/
controllers/
IndexController.php - IndexController
ErrorController.php - ErrorController
real/
controllers/
IndexController.php - Real_IndexController
BooController.php - Real_BooController

and ensure that you call:

$front->addModuleDirectory('path/to/modules');

in your bootstrap.

> I tried all versions and I get:
>
> Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with
> message 'Invalid controller specified (index)' in
> /var/www/snrk/library/Zend/Controller/Dispatcher/Standard.php:249 Stack
> trace: #0 /var/www/snrk/library/Zend/Controller/Front.php(919):
> Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
> Object(Zend_Controller_Response_Http)) #1
> /var/www/snrk/app/www/bootstrap.php(67): Zend_Controller_Front->dispatch()
> #2 /var/www/snrk/www/index.php(3): require_once('/var/www/snrk/a...') #3
> {main} thrown in
> /var/www/snrk/library/Zend/Controller/Dispatcher/Standard.php on line 249
>
> Is it necessary to add route because of each module?

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: