/**
* 应用程序初始化
*/
public static function start()
{
// 注册AUTOLOAD方法
spl_autoload_register('Think\\Think::autoLoad');
// 设定错误和异常处理
register_shutdown_function('Think\\Think::fatalError');
set_error_handler('Think\\Think::appError');
set_exception_handler('Think\\Think::appException');
// 初始化文件存储方式
Storage::connect(STORAGE_TYPE);
$runtimeFile = RUNTIME_PATH . APP_MODE . '~runtime.php';
if (!APP_DEBUG && Storage::has($runtimeFile)) {
Storage::load($runtimeFile);
} else {
$content = '';
// 读取应用模式
$mode = (include is_file(CONF_PATH . 'core.php') ? CONF_PATH . 'core.php' : MODE_PATH . APP_MODE . '.php');
// 加载核心文件
foreach ($mode['core'] as $file) {
if (is_file($file)) {
include $file;
if (!APP_DEBUG) {
$content .= compile($file);
}
}
}
// 加载应用模式配置文件
foreach ($mode['config'] as $key => $file) {
is_numeric($key) ? C(load_config($file)) : C($key, load_config($file));
}
}
}