Just to throw out another possible style. I use a Bootstrap class in 
./application/Bootstrap.php to segregate setup stages so I can pick and match a 
few to double as setups methods for my testing environment. A basic version 
without a mass of Controller setup steps but adding UTF-8 encoding as default 
would probably look like:

<?php

require_once 'Zend/Loader.php';

class Bootstrap
{

    public static $frontController = null;
    
    public static function run()
    {
        self::setupEnvironment();
        self::prepare();
        $response = self::$frontController->dispatch();
        self::sendResponse($response);
    }
    
    public static function setupEnvironment()
    {
        error_reporting(E_ALL|E_STRICT);
        ini_set('display_errors', true);
        date_default_timezone_set('Europe/London');
    }
    
    public static function prepare()
    {
        self::setupFrontController();
        self::setupView();
    }
    
    public static function setupFrontController()
    {
        Zend_Loader::registerAutoload();
        self::$frontController = Zend_Controller_Front::getInstance();
        self::$frontController->throwExceptions();
        self::$frontController->returnResponse(true);
        self::$frontController->setControllerDirectory(
            dirname(__FILE__) . '/controllers'
        );
    }
    
    public static function setupView()
    {
        $view = new Zend_View;
        $view->setEncoding('UTF-8');
        $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
        Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
    }
    
    public static function sendResponse(Zend_Controller_Response_Http $response)
    {
        $response->setHeader('Content-Type', 'text/html; charset=UTF-8', true);
        $response->sendResponse();
    }
    
}

A basic use would have the index.php looking like:

<?php

$root = dirname(dirname(__FILE__)); // amend for actual path

set_include_path(
    .$root . '/application' . PATH_SEPARATOR
    . $root . '/library' . PATH_SEPARATOR
    . get_include_path()
);

require 'Bootstrap.php';

Bootstrap::run();

I tend to use Bootstrap::prepare() as a general setup method for any Controller 
tests I write which is why it needs a specific gathering of bootstrap steps 
attached to it while excluding anything not necessary for test running.


Best regards,
Paddy
 
Pádraic Brady

http://blog.astrumfutura.com
http://www.patternsforphp.com
OpenID Europe Foundation


----- Original Message ----
From: Justin Mazzi <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, February 6, 2008 6:34:01 PM
Subject: Re: [fw-general] Dispatcher/Bootstrap ZF 1.5 PR


thanks 
for 
the 
help 
everyone!

On 
Feb 
5, 
2008, 
at 
11:04 
PM, 
Zarrar 
Shehzad 
wrote:

> 
Hi
>
> 
There 
is 
also 
an 
example 
project 
that 
you 
can 
download 
which 
has 
a
> 
default 
setup 
for 
zend 
framework 
to 
get 
you 
started:
> 
http://andries.systray.be/blog/2007/06/18/zend-framework-just-get-me-started-okay/
>
> 
Zarrar
>
> 
On 
Feb 
5, 
2008 
8:23 
PM, 
Garri 
Santos 
<[EMAIL PROTECTED]>  
> 
wrote:
>> 
Hi!
>>
>> 
TIMTOWTDI 
you 
can 
take 
a 
look 
at 
the 
sample 
provided 
at:
>> 
http://www.zend.com/en/resources/webinars/framework
>> 
Zend 
Framework 
and 
Access 
Control 
Webinar
>>
>> 
cheers,
>> 
Garri
>>
>>
>> 
On 
Feb 
6, 
2008 
6:15 
AM, 
jmazzi 
<[EMAIL PROTECTED]> 
wrote:
>>>
>>> 
Hi,
>>>
>>> 
Could 
someone 
post 
an 
example 
of 
the 
correct 
way 
to 
create 
a
>>> 
dispatcher/bootstrap 
for 
MVC? 
Is 
there 
even 
a 
preferred 
method?
>>> 
--
>>> 
View 
this 
message 
in 
context: 
http://www.nabble.com/Dispatcher-Bootstrap-ZF-1.5-PR-tp15299930s16154p15299930.html
>>> 
Sent 
from 
the 
Zend 
Framework 
mailing 
list 
archive 
at 
Nabble.com.
>>>
>>>
>>




Reply via email to