/** * Printemps initialization function * * @param array $cfg config options * @return bool if Printemps has succeessfully inited, return true */ public static function init($cfg = array()) { $basepath = dirname(__FILE__); /* default config file */ $_default = array("APP_ROOT_DIR" => $basepath, "APP_DEPENDENCE" => $basepath . '/dependence/', "APP_VIEWS" => $basepath . '/dependence/views/', "APP_CACHES" => $basepath . '/dependence/caches/', "APP_PUBLIC" => $basepath . '/public', "APP_ASSETS" => $basepath . '/public/assets/', "APP_NAME" => "Printemps Application", "APP_VERSION" => "1", "APP_DEBUG_MODE" => false, "APP_ENTRY_MODE" => 1, "APP_ERROR_HANDLER" => false); foreach ($_default as $key => $value) { if (isset($cfg['initial'][$key])) { define($key, $cfg['initial'][$key]); } else { define($key, $value); } } /** Register Autoload method*/ self::registerAutoload(); if (APP_ERROR_HANDLER) { set_error_handler(APP_ERROR_HANDLER, E_CORE_ERROR ^ E_USER_ERROR); } else { set_error_handler(array("Printemps_Exception", "halt"), E_CORE_ERROR ^ E_USER_ERROR); } set_error_handler(array("Printemps_Exception", "notice"), E_WARNING ^ E_NOTICE); //for notice / warning set_exception_handler(array("Printemps_Exception", "halt")); //for exception Printemps_Config::write($_default); Printemps_Config::write($cfg); isset($cfg['router']) && $cfg['router'] ? Printemps_Router::dispatch() : false; $_printemps = Printemps::getInstance(); return $_printemps; }