private static function initModule($module, $config) { // 定位模块目录 $module = COMMON_MODULE == $module || !APP_MULTI_MODULE ? '' : $module . DS; // 加载初始化文件 if (is_file(APP_PATH . $module . 'init' . EXT)) { include APP_PATH . $module . 'init' . EXT; } else { $path = APP_PATH . $module; // 加载模块配置 Config::load($module . 'config'); // 加载应用状态配置 if ($config['app_status']) { Config::load($module . $config['app_status']); } // 加载别名文件 if (is_file($path . 'alias' . EXT)) { Loader::addMap(include $path . 'alias' . EXT); } // 加载行为扩展文件 if (APP_HOOK && is_file($path . 'tags' . EXT)) { Hook::import(include $path . 'tags' . EXT); } // 加载公共文件 if (is_file($path . 'common' . EXT)) { include $path . 'common' . EXT; } // 加载当前模块语言包 if ($config['lang_switch_on'] && $module) { Lang::load($path . 'lang' . DS . LANG_SET . EXT); } } }
// ThinkPHP 引导文件 // 加载基础文件 require __DIR__ . '/base.php'; require CORE_PATH . 'loader.php'; // 注册自动加载 Loader::register(); // 注册错误和异常处理机制 register_shutdown_function(['think\\Error', 'appShutdown']); set_error_handler(['think\\Error', 'appError']); set_exception_handler(['think\\Error', 'appException']); // 加载模式定义文件 $mode = (require MODE_PATH . APP_MODE . EXT); // 加载模式别名定义 if (isset($mode['alias'])) { Loader::addMap(is_array($mode['alias']) ? $mode['alias'] : (include $mode['alias'])); } // 加载模式配置文件 if (isset($mode['config'])) { is_array($mode['config']) ? Config::set($mode['config']) : Config::load($mode['config']); } // 加载模式行为定义 if (APP_HOOK && isset($mode['tags'])) { Hook::import(is_array($mode['tags']) ? $mode['tags'] : (include $mode['tags'])); } // 自动生成 if ('sae' != APP_MODE && is_file(APP_PATH . 'build.php')) { Create::build(include APP_PATH . 'build.php'); } // 执行应用 !IN_UNIT_TEST && App::run(Config::get());
private static function initModule($module, &$config) { // 定位模块目录 $module = COMMON_MODULE == $module ? '' : $module . '/'; // 加载初始化文件 if (is_file(APP_PATH . $module . 'init' . EXT)) { include APP_PATH . $module . 'init' . EXT; } else { $path = APP_PATH . $module; // 加载模块配置 $config = Config::load($module . 'config'); // 加载应用状态配置 if ($config['app_status']) { $config = Config::load($module . $config['app_status']); } // 加载别名文件 if (is_file($path . 'alias' . EXT)) { Loader::addMap(include $path . 'alias' . EXT); } // 加载行为扩展文件 if (is_file($path . 'tags' . EXT)) { Hook::import(include $path . 'tags' . EXT); } // 加载公共文件 if (is_file($path . 'common' . EXT)) { include $path . 'common' . EXT; } } }
/** * 初始化模块 * @access private * @return void */ private static function initModule($path, &$config) { // 加载初始化文件 if (is_file($path . 'init' . EXT)) { include $path . 'init' . EXT; } else { // 检测配置文件 if (is_file($path . 'config' . EXT)) { $config = Config::set(include $path . 'config' . EXT); } // 检测额外配置 if ($config['extra_config_list']) { foreach ($config['extra_config_list'] as $conf) { if (is_file($path . $conf . EXT)) { $config = Config::set(include $path . $conf . EXT); } } } // 加载应用状态配置文件 if ($config['app_status'] && is_file($path . $config['app_status'] . EXT)) { $config = Config::set(include $path . $config['app_status'] . EXT); } // 加载别名文件 if (is_file($path . 'alias' . EXT)) { Loader::addMap(include $path . 'alias' . EXT); } // 加载公共文件 if (is_file($path . 'common' . EXT)) { include $path . 'common' . EXT; } // 加载行为扩展文件 if (is_file($path . 'tags' . EXT)) { Hook::import(include $path . 'tags' . EXT); } } }
private static function initModule($module, $config) { // 定位模块目录 $module = COMMON_MODULE == $module || !APP_MULTI_MODULE ? '' : $module . DS; // 加载初始化文件 if (is_file(APP_PATH . $module . 'init' . EXT)) { include APP_PATH . $module . 'init' . EXT; } else { $path = APP_PATH . $module; // 加载模块配置 $config = Config::load(APP_PATH . $module . 'config' . EXT); // 加载应用状态配置 if ($config['app_status']) { $config = Config::load(APP_PATH . $module . $config['app_status'] . EXT); } // 读取扩展配置文件 if ($config['extra_config_list']) { foreach ($config['extra_config_list'] as $name => $file) { $filename = $path . $file . EXT; Config::load($filename, is_string($name) ? $name : pathinfo($filename, PATHINFO_FILENAME)); } } // 加载别名文件 if (is_file($path . 'alias' . EXT)) { Loader::addMap(include $path . 'alias' . EXT); } // 加载行为扩展文件 if (APP_HOOK && is_file($path . 'tags' . EXT)) { Hook::import(include $path . 'tags' . EXT); } // 加载公共文件 if (is_file($path . 'common' . EXT)) { include $path . 'common' . EXT; } // 加载当前模块语言包 if ($config['lang_switch_on'] && $module) { Lang::load($path . 'lang' . DS . LANG_SET . EXT); } } }
// 自动识别调试模式 if (!defined('APP_DEBUG')) { $debug = getenv(ENV_PREFIX . 'APP_DEBUG'); define('APP_DEBUG', $debug); } // 加载模式定义文件 $mode = (require MODE_PATH . APP_MODE . EXT); // 加载模式命名空间定义 if (isset($mode['namespace'])) { Loader::addNamespace($mode['namespace']); } // 注册自动加载 Loader::register(); // 加载模式别名定义 if (isset($mode['alias'])) { Loader::addMap($mode['alias']); } // 注册错误和异常处理机制 Error::register(); // 加载模式配置文件 if (isset($mode['config'])) { is_array($mode['config']) ? Config::set($mode['config']) : Config::load($mode['config']); } // 加载模式行为定义 if (APP_HOOK && isset($mode['tags'])) { Hook::import($mode['tags']); } // 是否自动运行 if (APP_AUTO_RUN) { App::run(); }
<?php defined(SYS_PATH) or define("SYS_PATH", dirname(__FILE__) . "/"); require_once SYS_PATH . "classes/loader.php"; ini_set("display_errors", 1); Loader::addAutoLoad(); Loader::addMap(); Registry::init(); Router::addMap(); Router::init(); var_dump(Router::getParams()); if (Router::getParams() == NULL) { Subdomain::init(); } $controller = Router::getController(); $action = Router::getAction(); if ($controller == 'site' or $controller == 'admin' or $controller == 'stylecheet') { $controller::init($action); } else { header("Location: http://myclankonto.net/"); }