-- Fouzia Usman <[EMAIL PROTECTED]> wrote
(on Thursday, 09 November 2006, 06:50 AM -0800):
> I was able to test major part of Rob Allen's Zend Framework tutorial. It gave
> me a good understanding of the complete MVC style used by ZF.
>
> I am now proceeding to next step to find out how the control is handled when
> there are more than one controllers.
>
> In index.php file we specify finally the control to run the controllers.
>
> // run!
>
> $controller->run('./application/controllers');
Just a note: The above shouldn't work. It should be one of:
Zend_Controller_Front::run('./application/controllers');
// or
// assuming controller is an instance of Zend_Controller_Front
$controller->setControllerDirectory('./application/controllers');
$controller->dispatch();
> Where will the control go when there are more than one controllers ? How do I
> control the flow between 2 controllers ?
If there are multiple controllers in the directory, it just means more
URL routes are available. So, if you have:
application/
controllers/
FooController.php
// with methods indexAction() and barAction()
BarController.php
// with methods indexAction(), fooAction(), and
// bazAction()
you now have the following URL routes:
/foo
/foo/bar
/bar
/bar/foo
/bar/baz
You can also forward to methods in other controllers:
class FooController extends Zend_Action_Controller
{
public function barAction()
{
// do some processing
$this->_forward('bar', 'foo');
}
}
What this does is instruct the front controller that it needs to execute
BarController::fooAction() after processing the current action.
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/