public static function library() { //打包当前已经注册的类 zotop::register(include ZPATH_LIBRARIES . DS . 'zotop' . DS . 'library.php'); zotop::register(include APP_ROOT . DS . 'library.php'); $files = zotop::register(); $content = runtime::compile($files); if (!empty($content)) { file::write(ZPATH_RUNTIME . DS . APP_NAME . '.php', $content, true); } }
public static function runtime() { if (!is_file(ZOTOP_RUNTIME . DS . '~runtime.php')) { $registers = zotop::register(); $content = array(); $content[] = '<?php'; foreach ($registers as $file) { $content[] = file::compile($file); } $content[] = '?>'; file::write(ZOTOP_RUNTIME . DS . '~runtime.php', implode("\n", $content)); } //缓存配置文件 zotop::data(ZOTOP_RUNTIME . DS . '~config.php', zotop::config()); }
/** * 运行时执行,并加载相关文件 */ public static function run() { //打包配置文件 zotop::data(ZOTOP_PATH_RUNTIME . DS . 'config.php', zotop::config()); //打包全部hook文件 $hooks = runtime::compile(runtime::$hooks); if (!empty($hooks)) { file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APP_NAME . '_hooks.php', $hooks, true); } //加载hooks以便核心文件使用 zotop::load(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APP_NAME . '_hooks.php'); //打包核心文件 $libraries = zotop::register(); $libraries = runtime::compile($libraries); if (!empty($libraries)) { file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APP_NAME . '.php', $libraries, true); } }
/** * 运行时执行,并加载相关文件 */ public static function build() { runtime::config(); runtime::library(); runtime::hooks(); //打包配置文件 zotop::data(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION_GROUP . '.config.php', zotop::config()); //打包全部hook文件 $hooks = runtime::compile(runtime::$hooks); if (!empty($hooks)) { file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION_GROUP . '.hooks.php', $hooks, true); } //加载hooks以便核心文件使用 zotop::load(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION_GROUP . '.hooks.php'); //打包核心文件 $libraries = zotop::register(); $libraries = runtime::compile($libraries); if (!empty($libraries)) { file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION_GROUP . '.core.php', $libraries, true); } }
<?php zotop::register('page', APPROOT . DS . 'libraries' . DS . 'page.php'); zotop::register('controller', APPROOT . DS . 'libraries' . DS . 'controller.php'); zotop::register('url', APPROOT . DS . 'libraries' . DS . 'url.php'); zotop::register('form', APPROOT . DS . 'libraries' . DS . 'form.php'); zotop::register('dialog', APPROOT . DS . 'libraries' . DS . 'dialog.php');
define('ZOTOP_MODULES', ZOTOP . DS . 'modules'); define('ZOTOP_CONFIG', ZOTOP . DS . 'config'); define('ZOTOP_CACHE', ZOTOP . DS . 'cache'); define('ZOTOP_BACKUP', ZOTOP . DS . 'backup'); define('ZOTOP_DATA', ZOTOP . DS . 'data'); define('ZOTOP_RUNTIME', ZOTOP . DS . 'runtime'); define('TIME', time()); //加载核心文件 if (file_exists(ZOTOP_RUNTIME . DS . '~runtime.php') && $debug == 'ddd') { require ZOTOP_RUNTIME . DS . '~runtime.php'; } else { //加载系统核心 require ZOTOP_LIBRARIES . DS . 'zotop' . DS . 'core' . DS . 'zotop.php'; //注册别名,自动加载系统库文件 zotop::register(include ZOTOP_LIBRARIES . DS . 'zotop' . DS . 'library.php'); zotop::register(include APP_ROOT . DS . 'library.php'); } //配置的初始化 if (file_exists(ZOTOP_RUNTIME . DS . '~config.php')) { zotop::config(include ZOTOP_RUNTIME . DS . '~config.php'); } else { zotop::config(include ZOTOP_CONFIG . DS . 'zotop.php'); zotop::config(include ZOTOP_CONFIG . DS . 'setting.php'); zotop::config('zotop.database', include ZOTOP_CONFIG . DS . 'database.php'); zotop::config('zotop.application', include ZOTOP_CONFIG . DS . 'application.php'); zotop::config('zotop.module', include ZOTOP_CONFIG . DS . 'module.php'); zotop::config('zotop.router', include ZOTOP_CONFIG . DS . 'router.php'); } //启动底层系统 zotop::boot(); //hook的初始化
define('ZOTOP_WEB', ZOTOP . DS . 'web'); define('ZOTOP_LIB', ZOTOP_SYSTEM . DS . 'libraries'); define('ZOTOP_CONFIG', ZOTOP_WEB . DS . 'config'); define('ZOTOP_CACHE', ZOTOP_WEB . DS . 'cache'); define('ZOTOP_BACKUP', ZOTOP_WEB . DS . 'backup'); define('ZOTOP_DATA', ZOTOP_WEB . DS . 'data'); define('ZOTOP_RUNTIME', ZOTOP_WEB . DS . 'runtime'); //加载核心文件 if (is_file(ZOTOP_APP . DS . '~runtime.php')) { require ZOTOP_APP . DS . '~runtime.php'; } else { //加载系统核心 require ZOTOP_LIB . DS . 'zotop' . DS . 'core' . DS . 'zotop.php'; //注册别名,自动加载系统库文件 zotop::register(include ZOTOP_LIB . DS . 'alias.php'); zotop::register(include ZOTOP_APP . DS . 'alias.php'); } //配置的初始化 if (is_file(ZOTOP_RUNTIME . DS . '~config.php')) { zotop::config(include ZOTOP_RUNTIME . DS . '~config.php'); } else { zotop::config(include ZOTOP_SYSTEM . DS . 'config.php'); zotop::config(include ZOTOP_CONFIG . DS . 'config.php'); zotop::config('zotop.database', include ZOTOP_CONFIG . DS . 'database.php'); zotop::config('zotop.application', include ZOTOP_CONFIG . DS . 'application.php'); zotop::config('zotop.module', include ZOTOP_CONFIG . DS . 'module.php'); zotop::config('zotop.router', include ZOTOP_CONFIG . DS . 'router.php'); //缓存配置文件 zotop::data(ZOTOP_RUNTIME . DS . '~config.php', zotop::config()); } //启动底层系统
define('ZOTOP_PATH_LIBRARIES', ZOTOP_PATH_SYSTEM . DS . 'libraries'); define('ZOTOP_PATH_BACKUP', ZOTOP_PATH_SYSTEM . DS . 'backup'); define('ZOTOP_PATH_DATA', ZOTOP_PATH_SYSTEM . DS . 'data'); define('ZOTOP_PATH_CACHE', ZOTOP_PATH_SYSTEM . DS . 'cache'); define('ZOTOP_PATH_RUNTIME', ZOTOP_PATH_SYSTEM . DS . 'runtime'); //定义URL常量 define('ZOTOP_URL_ROOT', dirname($_SERVER['SCRIPT_NAME'])); define('ZOTOP_URL_SYSTEM', ZOTOP_URL_ROOT . '/' . basename(ZOTOP_PATH_SYSTEM)); define('ZOTOP_URL_MODULES', ZOTOP_URL_ROOT . '/' . basename(ZOTOP_PATH_MODULES)); //定义app常量 define('ZOTOP_APP_NAME', ZOTOP_APP); define('ZOTOP_APP_ROOT', ZOTOP_PATH_APPLICATION . DS . ZOTOP_APP_NAME); define('ZOTOP_APP_URL', ZOTOP_URL_SYSTEM . '/' . ZOTOP_APP_NAME); //加载系统核心文件 if (file_exists(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APP_NAME . '.php') && !DEBUG) { require ZOTOP_PATH_RUNTIME . DS . ZOTOP_APP_NAME . '.php'; //加载hook文件 zotop::load(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APP_NAME . '_hooks.php'); //加载配置参数 zotop::config(include ZOTOP_PATH_RUNTIME . DS . DS . 'config.php'); //系统启动 zotop::boot(); } else { //加载系统核心 require ZOTOP_PATH_LIBRARIES . DS . 'zotop' . DS . 'classes' . DS . 'zotop.php'; //注册自动加载系统库文件 zotop::register(include ZOTOP_PATH_LIBRARIES . DS . 'zotop' . DS . 'classes.php'); zotop::register(include ZOTOP_APP_ROOT . DS . 'libraries' . DS . 'classes.php'); //重载系统 zotop::build(); }
//定义系统库文件的存放位置,zotop主框架就存放在该目录下 define('WWWROOT', dirname(SYSROOT)); //定义zotop的根目录,该目录可能并不是网站的根目录,但是一定是SYSROOT的上级目录,该目录名称有待商定,WWWROOT一般指的是网站的根目录 define('SITEROOT', WWWROOT . DS . 'site'); //定义用户目录,所有的用户文件都存储与该目录,除该目录外,整个网站的其他目录都是可以抛弃的,便于备份和升级,该目录名称待定 define('PLUGINSROOT', SITEROOT . DS . 'plugins'); //定义插件目录 //加载编译的核心库,如果未编译则直接加载需要文件,开发模式不编译 if (is_file(LIBROOT . DS . '~runtime.php')) { require LIBROOT . DS . '~runtime.php'; } else { //将系统核心部分(alias.php)中的文件打包 require LIBROOT . DS . 'zotop' . DS . 'core' . DS . 'zotop.php'; require LIBROOT . DS . 'zotop' . DS . 'core' . DS . 'functions.php'; //启动系统 zotop::register(include LIBROOT . DS . 'alias.php'); //zotop::boot(); //编译系统核心 } //系统启动 zotop::boot(); //TODO 加载配置代码暂时放在这儿 //加载 系统配置 @zotop::config(include SITEROOT . DS . 'config.php'); //加载全局配置,如果找不到这个配置文件就会重新生成缓存 @zotop::config(include SYSROOT . DS . 'config.php'); //加载编辑的插件部分,暂时不处理此部分 /* if(is_file(PLUGINSROOT.DS.'~runtime.php')) { require PLUGINSROOT.DS.'~runtime.php';
/** * 应用程序重启 * * * @return null */ public static function reboot() { //清理运行时文件 folder::clear(ZOTOP_PATH_RUNTIME); //加载全部配置 zotop::config(@(include ZOTOP_PATH_DATA . DS . 'config.php')); zotop::config('zotop.database', @(include ZOTOP_PATH_DATA . DS . 'database.php')); zotop::config('zotop.application', @(include ZOTOP_PATH_DATA . DS . 'application.php')); zotop::config('zotop.module', @(include ZOTOP_PATH_DATA . DS . 'module.php')); zotop::config('zotop.router', @(include ZOTOP_PATH_DATA . DS . 'router.php')); zotop::register(@(include ZOTOP_PATH_MODULES . DS . 'system' . DS . 'libraries.php')); zotop::register(@(include ZOTOP_PATH_APPLICATION . DS . 'libraries.php')); //加载全部开启模块的hook以及注册类文件 $modules = zotop::config('zotop.module'); foreach ((array) $modules as $module) { if ((int) $module['status'] >= 0 && folder::exists($module['path'])) { //加载库文件 zotop::register(@(include path::decode($module['path']) . DS . 'libraries.php')); //加载hook文件 application::$hooks[] = $module['path'] . DS . 'hooks' . DS . ZOTOP_APPLICATION . '.php'; } } //打包配置文件 zotop::data(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.config.php', zotop::config()); //打包hook文件 file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.hooks.php', application::compile(application::$hooks), true); //加载hooks以便核心文件使用 zotop::load(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.hooks.php'); //打包类文件 file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.core.php', application::compile(zotop::register()), true); }
define('ZOTOP_PATH_CACHE', ZOTOP_PATH_DATA . DS . 'cache'); define('ZOTOP_PATH_RUNTIME', ZOTOP_PATH_DATA . DS . 'runtime'); define('ZOTOP_PATH_APPLICATION', ZOTOP_PATH_ROOT . DS . 'site'); //定义URL路径及参数 define('ZOTOP_URL_ROOT', dirname($_SERVER['SCRIPT_NAME'])); define('ZOTOP_URL_MODULES', ZOTOP_URL_ROOT . '/modules'); define('ZOTOP_URL_THEMES', ZOTOP_URL_ROOT . '/themes'); define('ZOTOP_URL_COMMON', ZOTOP_URL_ROOT . '/site/common'); //加载运行文件 if (file_exists(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.core.php') && !DEBUG) { require ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.core.php'; //加载hook文件 zotop::load(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.hooks.php'); //加载配置参数 zotop::config(include ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION . '.config.php'); //系统启动 zotop::boot(); } else { //加载系统核心 require ZOTOP_PATH_MODULES . DS . 'system' . DS . 'libraries' . DS . 'zotop.php'; //注册自动加载系统库文件 zotop::register(@(include ZOTOP_PATH_MODULES . DS . 'system' . DS . 'libraries.php')); zotop::register(@(include ZOTOP_PATH_APPLICATION . DS . 'libraries.php')); zotop::reboot(); } //系统启动并运行 zotop::run('system.init'); zotop::run('system.route'); zotop::run('system.ready'); zotop::run('system.run'); zotop::run('system.shutdown');
define('ZOTOP_MODULES', ZOTOP . DS . 'modules'); define('ZOTOP_CONFIG', ZOTOP . DS . 'config'); define('ZOTOP_CACHE', ZOTOP . DS . 'cache'); define('ZOTOP_BACKUP', ZOTOP . DS . 'backup'); define('ZOTOP_DATA', ZOTOP . DS . 'data'); define('ZOTOP_RUNTIME', ZOTOP . DS . 'runtime'); define('TIME', time()); //加载核心文件 if (is_file(ZOTOP_RUNTIME . DS . '~runtime.php') && $debug == 'ddd') { require ZOTOP_RUNTIME . DS . '~runtime.php'; } else { //加载系统核心 require ZOTOP_LIBRARIES . DS . 'zotop' . DS . 'core' . DS . 'zotop.php'; //注册别名,自动加载系统库文件 zotop::register(include ZOTOP_LIBRARIES . DS . 'alias.php'); zotop::register(include APP_ROOT . DS . 'alias.php'); } //配置的初始化 if (file_exists(ZOTOP_RUNTIME . DS . '~config.php')) { zotop::config(include ZOTOP_RUNTIME . DS . '~config.php'); } else { zotop::config(include ZOTOP_CONFIG . DS . 'zotop.php'); zotop::config(include ZOTOP_CONFIG . DS . 'setting.php'); zotop::config('zotop.database', include ZOTOP_CONFIG . DS . 'database.php'); zotop::config('zotop.application', include ZOTOP_CONFIG . DS . 'application.php'); zotop::config('zotop.module', include ZOTOP_CONFIG . DS . 'module.php'); zotop::config('zotop.router', include ZOTOP_CONFIG . DS . 'router.php'); } //启动底层系统 zotop::boot(); //hook的初始化