-- ZegeeDotCom <[EMAIL PROTECTED]> wrote
(on Monday, 19 March 2007, 08:22 AM -0700):
> Can someone provide a good example for the bootstrap file ???
> The changes to the 0.9 versions are not clear.....and all my code that
> worked under 0.8 doesnt do anything, I cant even see any exceptions - zero,
> nada.
> 
> Please give a more thorough explanation for how the controller and views are
> set up in the bootstrap.

Surprisingly, bootstraps have basically remained unchanged from 0.6 to
0.9. The primary difference has to do with whether or not you want to
handle exceptions yourself, or have them swallowed by the response
object, and there are good examples for this in the manual (see the
section on "MVC Exceptions").

The most basic version:

    require_once 'Zend/Controller/Front.php';
    Zend_Controller_Front::run('../application/controllers');

One that has exceptions thrown:

    require_once 'Zend/Controller/Front.php';
    Zend_Controller_Front::getInstance()->throwExceptions(true);
    Zend_Controller_Front::run('../application/controllers');

One that instantiates a view object for later use:

    require_once 'Zend/Controller/Front.php';
    require_once 'Zend/View.php';
    $front = Zend_Controller_Front::getInstance();
    $front->setControllerDirectory('../application/controllers')
          ->throwExceptions(true)
          ->setParam('view', new Zend_View());
    $front->dispatch();

Of course, you don't need to set the view object anymore, as you can
use initView() and render() in the action controller; however, I haven't
documented those features yet. Here's what I wrote in the commit
message, though:

  r3918 | matthew | 2007-03-14 07:47:30 -0400 (Wed, 14 Mar 2007) | 15 lines
  
  [ZF-1020]:
    Close session using Zend_Session when Zend_Session is in use
  View integration proposal:
    Add view integration to Zend_Controller_Action. Creates two new
    methods:
    - initView(): returns $this->view if a Zend_View_Interface;
      otherwise, instantiates a Zend_View object, using sane defaults
      for view directory placement
    - render(): renders a template and places it in the response object.
      By default, uses <controller>/<action>.phtml as script name, but
      can override suffix in the object, action, or omit controller. By
      default, appends content to default body content segment of
      response object; if $name provided, appends to that segment
      instead.

Basically, if you need to handle exceptions or modify the front
controller environment in any way -- setting parameters, adding
controller modules, using a custom request or response object, etc.,
it's better to grab your front controller instance and then later call
dispatch(). 

> ZegeeDotCom wrote:
> > 
> > I am not seeing anything. No errors, no html and I thought that maybe I am
> > setting up the controller incorrectly:
> > 
> > include "Zend/Loader.php";                  
> >             Zend_Loader::loadClass('Zend_Controller_Front');
> >             $front = 
> > Zend_Controller_Front::run('../application/controllers');
> >             $front->throwExceptions(true);          
> > 
> > does this look good enough?
> > 
> > in my previous 0.8 framework, things worked really well...
> > 
> > 
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/bootstrap-controller-setup...-tf3427552s16154.html#a9554042
> Sent from the Zend Framework mailing list archive at Nabble.com.
> 

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to