-- debussy007 <[EMAIL PROTECTED]> wrote
(on Tuesday, 11 September 2007, 02:38 PM -0700):
> I have the below code from a Zend Tutorial illustrating how to initialize an
> application based on MVC pattern.
> (http://www.zftutorials.com/introduction-zend-framework/Zend-Framework-Getting-Started-Screencasts-l219.html)
>
> But what I don't understand is that every request on the web site will, I
> think, execute the initialization code.
>
> Isn' it better to load this code only once ? Or does this code need to be
> executed on every request ?
> Thank you.
>
> (I am JSP developer and in a j2ee app I would rather initialise the
> application in a load-on-startup servlet.)
Unlike J2EE, PHP has a shared nothing architecture; every request is
independent of all others. So yes, this initialization code is
performed for every request, and not specific to ZF.
> <?php
> error_reporting(E_ALL|E_STRICT);
> ini_set('display_errors', 'on');
> ini_set('include_path', ini_get('include_path') . ';../library');
> require "Zend/Loader.php";
> Zend_Loader::loadClass('Zend_Controller_Front');
> Zend_Loader::loadClass('Zend_Config_Xml');
> $config = new Zend_Config_Xml('../application/config/config.xml','dev');
> $front = Zend_Controller_Front::getInstance();
> $front->setControllerDirectory('../application/controllers');
> if($config->test)
> $front->throwExceptions(true);
> $front->dispatch();
> ?>
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/