Source for file index.php
Documentation is available at index.php
* DotBoost Technologies Inc.
* DotKernel Application Framework
* @copyright Copyright (c) 2009 DotBoost Technologies (http://www.dotboost.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @version $Id: index.php 151 2010-06-14 13:54:43Z teo $
* Main public executable wrapper.
* Setup environment, setup index controllers , and load module to run
* @author DotKernel Team <team@dotkernel.com>
// Start counting the time needed to display all content, from the very beginning
// Define application environment
define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
//Set include path to library directory
// Define PATH's (absolute paths) to configuration, controllers, DotKernel, templates directories
defined('CONFIGURATION_PATH') || define('CONFIGURATION_PATH', realpath(dirname(__FILE__ ). '/configs'));
defined('CONTROLLERS_PATH') || define('CONTROLLERS_PATH', realpath(dirname(__FILE__ ). '/controllers'));
defined('DOTKERNEL_PATH') || define('DOTKERNEL_PATH', realpath(dirname(__FILE__ ). '/DotKernel'));
defined('TEMPLATES_PATH') || define('TEMPLATES_PATH', realpath(dirname(__FILE__ ). '/templates'));
// Define DIRECTORIES ( relative paths)
defined('TEMPLATES_DIR') || define('TEMPLATES_DIR', '/templates');
require_once 'Zend/Loader/Autoloader.php';
$zend_loader = Zend_Loader_Autoloader::getInstance();
//includes all classes in library folder. That class names must start with Dot_
$zend_loader->registerNamespace('Dot_');
// Create registry object, as read-only object to store there config, settings, and database
$registry = new Zend_Registry(array(), ArrayObject::ARRAY_AS_PROPS);
Zend_Registry::setInstance($registry);
//Load configuration settings from application.ini file and store it in registry
$registry->configuration = $config;
//Load resource(modules, controllers, actions) settings from resource.ini file and store it in registry
$registry->resource = $resource;
// Create connection to database, as singleton , and store it in registry
$db = Zend_Db::factory('Pdo_Mysql', $config->database->params->toArray());
$registry->database = $db;
//Load specific configuration settings from database, and store it in registry
$registry->settings = $settings;
//Set PHP configuration settings from application.ini file
// Start Index Controller
// We are in frontend or in other module ? Prebuilt modules: frontend, admin, rss
$requestModule = 'frontend';
if (in_array($requestRaw['0'], $config->resources->modules->toArray()))
// if we are NOT in frontend module
if ($requestModule != 'frontend')
// set Controller and Action value, default Index
$requestController = 'Index';
if (isset ($requestRaw['0']) && $requestRaw['0'] != '')
// set Action value, default nothing
if (isset ($requestRaw['1']) && $requestRaw['1'] != '')
// we have extra variables, so we load all in the global array $request
while (list ($key, $val) = each($requestRaw))
$request[$val] = current($requestRaw);
// remove first element of the request array, is module and action in it
//memory request into param variable and load them into registry
$param['module'] = $requestModule;
$param['controller'] = $requestController;
$param['action'] = $requestAction;
$registry->param = $param;
// Start dotKernel object
$session = Zend_Registry::get('session');
* From this point , the control is taken by the Front Controller
* call the Front Controller specific file, but check first if exists
$frontControllerPath = CONTROLLERS_PATH. '/'. $requestModule. '/'. 'IndexController.php';
!file_exists($frontControllerPath) ? $dotKernel->pageNotFound() : require ($frontControllerPath);
|