(on Friday, 18 July 2008, 04:48 PM -0700):
>
> I didn't quite understand that (well, actually I did but, models = modules?)
No, models != modules. Modules are standalone functionality that include
their own controllers and view scripts (and, potentially, models).
Models are your business processes and data access layers. You define a
module when you add a controller directory to the front controller. If
you have only one controller directory, which is typical, that is the
"default" module.
> anyway, after reading the manual I ran
> Zend_Controller_Front::run('application/CMS/controllers') and it started
> working again. Yet I will try setting the module to that one and see what
> happens.
>
> I read the manual that it goes like this:
> 1) getInstance
> 2) setController
> 3) Use ::run to run default controller
No.
Standard workflow is:
* get front controller instance
* configure front controller instance
* including setting any controller directories (modules)
* dispatch() the front controller instance
run() is used when you have only a single module, and can be used as a
shortcut to set the controller directory and dispatch() in a single
line.
So, it's the difference between:
$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory('application/controllers/');
$front->dispatch();
and:
Zend_Controller_Front::run('application/controllers/');
I believe the OP has figured out their issue, which involves having
multiple modules, but none of them defined as the default, fallback
module.
> Nguyen Kha wrote:
> >
> > I think you must special one of two module's name is 'default' or use
> > 'setDefaultModule' method to set ImageHost is default module :-)
> >
> >
> > David G. wrote:
> >>
> >> Well, I wanted to separate the administration controllers from the main
> >> site logical code. This is my first time doing it and thought I would
> >> give it a try for the sake of not overcomplicating my life.
> >>
> >> Here's the code
> >>
> >> <?php
> >> /**
> >> * CMS Skeleton
> >> *
> >> * #@author: David Gonzalez
> >> */
> >>
> >> error_reporting(E_ALL|E_STRICT);
> >>
> >> ini_set('display_startup_errors', 1);
> >> ini_set('display_errors',1);
> >>
> >> set_include_path('./library' . PATH_SEPARATOR . get_include_path());
> >>
> >> require_once 'Zend/Loader.php';
> >>
> >> Zend_Loader::registerAutoload();
> >>
> >>
> >> $frontier = Zend_Controller_Front::getInstance();
> >> $frontier->throwExceptions(1);
> >>
> >> $frontier->setControllerDirectory(
> >> array('ImageHost' => 'application/CMS/controllers',
> >> 'ImageHostAdmin' => 'application/CMSAdmin/controllers')
> >> );
> >>
> >> var_dump($frontier->getModuleControllerDirectoryName());
> >>
> >> $frontier->dispatch();
> >>
> >> ?>
> >>
> >>
> >> Can someone explain why ZF is throwing this message at me?
> >>
> >> Fatal error: Uncaught exception 'Zend_Controller_Exception' with message
> >> 'No default module defined for this application' in
> >> C:\WebServer\Apache2\htdocs\CMS\library\Zend\Controller\Dispatcher\Standard.php:392
> >> Stack trace: #0
> >> C:\WebServer\Apache2\htdocs\CMS\library\Zend\Controller\Dispatcher\Standard.php(211):
> >> Zend_Controller_Dispatcher_Standard->getControllerClass(Object(Zend_Controller_Request_Http))
> >> #1
> >> C:\WebServer\Apache2\htdocs\CMS\library\Zend\Controller\Dispatcher\Standard.php(245):
> >> Zend_Controller_Dispatcher_Standard->isDispatchable(Object(Zend_Controller_Request_Http))
> >> #2
> >> C:\WebServer\Apache2\htdocs\CMS\library\Zend\Controller\Front.php(914):
> >> Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
> >> Object(Zend_Controller_Response_Http)) #3
> >> C:\WebServer\Apache2\htdocs\CMS\index.php(29):
> >> Zend_Controller_Front->dispatch() #4 {main} thrown in
> >> C:\WebServer\Apache2\htdocs\CMS\library\Zend\Controller\Dispatcher\Standard.php
> >> on line 392
> >>
> >> I checked the API Doc and the documentation but I didn't quite find a
> >> real answer to this, hope someone could explain this to me, I'd really
> >> appreciate it. I want to continue learning ZF.
> >>
> >> Thanks,
> >> David
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Question-about-setControllerDirectory-tp18538214p18539546.html
> Sent from the Zend MVC mailing list archive at Nabble.com.
>
--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论