/** * Initialization * * Determine error handling configuration ans setup correspondent properties. * * This functions wiil be executes one time before first error/eception or never * if error/exception hasn't occur. */ static function init() { if (self::$rootDir) { return; } try { $c = Config::getInstance(); $root_dir = $c->root_dir; $data_dir = $c->data_dir; } catch (Exception $e) { $root_dir = dirname(dirname(__FILE__)); $data_dir = '/data'; } self::$rootDir = $root_dir; $textTemplate = $root_dir . $data_dir . '/exceptionTemplate.text.php'; $webTemplate = $root_dir . $data_dir . '/exceptionTemplate.web.php'; // errors will be logged if (self::iniToBool(ini_get('log_errors'))) { self::$logTemplate = $textTemplate; } // errors wiil be displayed if (self::iniToBool(ini_get('display_errors'))) { // in console(CLI) and Ajax we preffered to display errors in plain text self::$displayTemplate = php_sapi_name() == 'cli' || Controller::getInstance()->isAjax() ? $textTemplate : $webTemplate; } }
/** * Require some common files and classes */ require "functions.php"; //require("exceptions.php"); //require("interfaces.php"); require "env/Loader.php"; require "Config.php"; require 'Autoload.php'; require 'ErrorsHandler.php'; /** * Setup errors and exceptions handlers. * * @see ErrorsHandler */ ErrorsHandler::setup(); /** * Init config with CONFIG and CONFIG_SECTION constants * If they are not defined, "config.ini" and "config" are used instead. * In current implementation use IniDBConfig only */ Config::init(new IniDBConfig()); /** * Init helper class to lookup and include classes. One class per file is allowed. * Name of the file must be the same as class name. */ Autoload::init(); /** * Connect to database. All parameters defined in configuration file */ DB::init(Config::getInstance()->db);