classApp { Public Static functioninit () {load_ext_file (common_path);//{///home/www/www.domain.com/myapp/common/common/<load_ext_file,field1>.php/// home/www/www.domain.com/myapp/common/conf/<load_ext_config,config1>.php//}//URL schedulingDispatcher::Dispatch ();// {////...////Match out module////...////Load module configuration file/home/www/www.domain. com/myapp/module1/conf/config.php//if (Is_file (Module_path. ' Conf/config '. Conf_ext)//C (Load_config (Module_path. ') Conf/config '. Conf_ext))//////////Load Application Mode corresponding Profile//if (' common '! = App_mode && is_file (module_path. ') Conf/config_ '. App_mode. Conf_ext)//C (Load_config (Module_path. ') Conf/config_ '. App_mode. Conf_ext))/////////////if (App_status && is_file (Module_path. ') for the current application state conf/'. App_status. Conf_ext)//C (Load_config (Module_path. ') conf/'. App_status. Conf_ext)); Load module alias definition/home/www/www.domain.com/myapp/module1/conf/alias.php//if (is_file (Module_path. ' conf/alias.php ')//Think::addmap (include Module_path. ') Conf/alias.php ');///load module tags file definition/home/www/www.domain.com/myapp/module1/conf/tags.php// if (Is_file (Module_path. ') conf/tags.php ')//Hook::import (include Module_path. ') conf/tags.php ')////Load module function file/home/www/www.domain.com/myapp/module1/conf/function.php//if (is_f Ile (Module_path. ' common/function.php ')//include Module_path. ' Common/function.php '; Load module extension profile//load_ext_file (Module_path);////{//////home/www/ www.domain.com/myapp/Module1/Common/Common/<LOAD_EXT_FILE,field1>.php/////home/www/www.domain.com/ myapp/module1/common/conf/<load_ext_config,config1>.php////}////Get Controller namespace (path)// Controller////Get control and operation name////action//}Hook:: Listen (' Url_dispatch '); } Public Static functionrun () {//Apply Initialize TagHook::listen (' App_init ');//Execute app_init tag behavior, no return value//{//behavior\buildlitebehavior//}App:: Init ();//******* introduces other files, parses the routes, and introduces the relevant configuration in the module *******Hook:: Listen (' App_begin ');//{//behavior\readhtmlcachebehavior//}//Session initialization if(!is_cli) {Session (C (' Session_options ')); } App::exec();//******* executes the code based on the parsed route *******Hook:: Listen (' App_end ');//{//behavior\showpagetracebehavior//} } Public Static function exec() { if(!Preg_match('/^[a-za-z] (\/|\w) *$/', controller_name)) {//Safety Testing $module=false; }ElseIf(C (' Action_bind_class ')){ //action Binding to class: module \controller\ controller \ Operation $layer= C (' Default_c_layer '); if(Is_dir(Module_path.$layer.‘ /‘. Controller_name)) {///HOME/WWW/WWW.DOMAIN.COM/MYAPP/MODULE1/CONTROLLER/CTRL1 $namespace= Module_name. ' \\‘.$layer.‘ \\‘. Controller_name. ' \\‘;//\module1\controller\ctrl1\}Else{ //NULL Controller $namespace= Module_name. ' \\‘.$layer.‘ \\_empty\\ ';//\module1\controller\_empty\ } $actionName=Strtolower(Action_name); if(class_exists($namespace.$actionName)){//\module1\controller\ctrl1\action1 $class=$namespace.$actionName; }ElseIf(class_exists($namespace.‘ _empty ')) {//\module1\controller\ctrl1\_empty//null operation $class=$namespace.‘ _empty '; }Else{E (L (' _error_action_ '). ': '.action_name); } $module=New $class; //the operation is bound to the class and the run entry is fixed $action= ' Run '; }Else{ //Create a controller instance $module= Controller (Controller_name,Controller_path); //{//new \module1\controller\ctrl1//new \addon\$_get[' Addon ']\controller \ctrl1//} } if(!$module) { if(' 4e5e5d7364f443e28fbf0d3ae744a59a ' = =controller_name) { Header("Content-type:image/png"); Exit(Base64_decode(APP::logo ())); } //whether to define the empty controller $module= A (' Empty ');//Emptycontroller if(!$module) {E (L (' _controller_not_exist_ '). ': '.controller_name); } } //get current operation name supports dynamic routing if(!isset($action)){ $action= Action_name. C (' Action_suffix '); } Try{ Self:: Invokeaction ($module,$action);//execution Behavior Method}Catch(\reflectionexception$e) { //method call occurs after an exception is booted to the __call method processing $method=New\reflectionmethod ($module, ' __call '); $method->invokeargs ($module,Array($action,‘‘));//{//Emptycontroller::__call ()//Ctrl1controller::__call ()//} } return ; }}
thinkphp 3.2.3-app.class.php Analysis