Hi,
A few questions regarding the basics of Zend Framework 1.9.
i followed the quickstart guide, and basically, bootstrapping involves,
a. from index.php:
$ZEND_FRAMEWORK_LIB_PATH = '/appl/ZendFramework-1.9.7/library'; defined('APPLICATION_PATH') || define('APPLICATION_PATH', (realpath(dirname(__FILE__) . '/../application'))); defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); set_include_path(implode(PATH_SEPARATOR, array((dirname(dirname(__FILE__)) . '/library'), $ZEND_FRAMEWORK_LIB_PATH, get_include_path(),))); require_once 'Zend/Application.php'; $application = new Zend_Application(APPLICATION_ENV, (APPLICATION_PATH . '/configs/application.ini')); $application->bootstrap()->run();
b. Then in the Bootstrap.php, i have
protected function _initAutoload() { $autoloader = new Zend_Application_Module_Autoloader(array("namespace" => "Default_", "basePath" => dirname(__FILE__),)); return $autoloader; } protected function _initDoctype() { $this->bootstrap("view"); $view = $this->getResource("view"); $view->doctype("XHTML1_STRICT"); }
For a start, a few things i don't understand:
a. If a user access the site not via the default index.php, does that mean that bootstrapping (and indeed, all the code in the index.php including setting of environment etc, will be bypassed?)
b. There is no place that explicitly calls the Bootstrap's
_initAutoload()
or_initDoctype()
methods. So when are these methods implicitly invoked?c. Since in the index.php, i have already "passed in" the config file
'/configs/application.ini'
to the Zend_Application constructor, is there any way to retrieve the config entries elsewhere?In my application, i have to work with different databases (so i can't just use
resources.db.*
). So in the same application.ini file, i have, e.g.custdb.adapter = "PDO_MYSQL" custdb.params.host = "localhost" custdb.params.username = "username" custdb.params.password = "password" custdb.params.dbname = "custdb"
What's the best practice to manage the DB adapter?
a. Is it possible to (and should i) create the DB adapter in index.php OR Bootstrap.php and retrieve it elsewhere when needed (and how)?
b. Or is possible to (and should i) just retrieve the config entries elsewhere (how?) and instantiate the DB adapter as and when needed?
Thanks!