22 Nov
Posted by Ganesh H S , Bangalore, India as zend framework
To completely understand the bootstrap files, you need to read all the tutorials of zend framework. I will cover all this topics in upcoming tutorials.
Lets start writing the bootstrap file public/index.php -
<?php
/**
* Bootstrap file for zend framework
*
* Set the environment settings of zend framework
*
* PHP versions 5.1.4+
*
*
* @category zend framework tutorials
* @author Ganesh H S <me@ganeshhs.com>
* @copyright Ganesh H S
* @link http://framework.zend.com
*/
error_reporting(E_ALL|E_STRICT);
ini_set("display_errors", "on");
set_include_path(get_include_path()
. PATH_SEPARATOR . '../library/'
. PATH_SEPARATOR . '../application/models/'
);
/**
* Zend Loader
*/
require_once "Zend/Loader.php";
/**
* Required classes
*/
Zend_Loader::loadClass('Zend_Controller_Front');
Zend_Loader::loadClass('Zend_Config_Ini');
Zend_Loader::loadClass('Zend_View');
Zend_Loader::loadClass('Zend_Session');
Zend_Loader::loadClass('Zend_Log');
Zend_Loader::loadClass('Zend_Controller_Request_Http');
Zend_Loader::loadClass('Zend_Debug');
Zend_Loader::loadClass('Zend_Auth');
Zend_Loader::loadClass('Zend_Db');
Zend_Loader::loadClass('Zend_Db_Table');
Zend_Loader::loadClass('Zend_Registry');
/**
* Intialize zend Session
*/
Zend_Session::start();
/**
* Set the auth namespace
*/
require_once "Zend/Session/Namespace.php";
$consumer = new Zend_Session_Namespace("consumer");
Zend_Registry::set('consumer', $consumer);
/**
* Set config
*/
$config = new Zend_Config_Ini("../application/config.ini", "staging");
/**
* Set the database
*/
// setup database
$db = Zend_Db::factory($config->db->adapter,
$config->db->config->toArray());
Zend_Registry::set('config', $config);
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('db', $db);
/**
* Intialize zend log
*/
require_once "Zend/Log/Writer/Stream.php";
// Write log to file
$writer = new Zend_Log_Writer_Stream('path to file');
$logger = new Zend_Log($writer);
Zend_Registry::set('logger', $logger);
/*
* Setup controller
*/
$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory('../application/controllers');
$front->setParam('noViewRenderer', true);
if($config->staging)
{
$front->throwExceptions(true);
}
else
{
$front->throwExceptions(false);
}
$front->dispatch();
?>
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jul | ||||||
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
RSS feed for comments on this post · TrackBack URI
Leave a reply