[Li Jingshan php] every day tp5-20161212| App.php-2

Source: Internet
Author: User

Public static function run (request  $request  = null) {// thinkphp after   Automatic loading, error takeover, configuration file presets, and finally began to execute.     //  First step: Get request Parameters     is_null ($request)  && $ Request = request::instance ();     // self:: $instance  = new  Static ($options);  executed   This  instance    //  default   No value passed in,is_null  So execute   back   $request  = request::instance ();    //  This notation   true   Very classic, I like you, Lao Liu, haha     //  finally acquired   a  request  object     $ Config = self::initcommon ();//  load   Initialize   configuration   file   options     //  2016-10-09    if  (Defined (' Bind_module '))  {//  default here is undefined          //  module/Controller binding         bind_ Module&nBsp;&& route::bind (Bind_module);//self:: $bind  = [' type '  =>  $type,  $ type =>  $bind];        //  on the  $ of  Route      } elseif  ($config [' Auto_bind_module '])  {//  default here is also undefined          //  Entrance Auto-binding          $name  =  pathinfo ($request->basefile (),  pathinfo_filename);         if  ($name  &&  ' index '  !=  $name  && is_dir (app_path  .  $name))  {            route::bind ($name);         }    }    $ Request->filter ($config [' Default_filter ']);//  specify   filter   parameters   NULL   direct   return      try {        //  Open Multi-lingual mechanism         if   ($config [' lang_switch_on '])  {             //  get current language              $request Langset (Lang::d etect ());            //  Load System Language Pack             lang::load (THINK_PATH .   ' lang '  . DS .  $request->langset ()  . ext);//  loading   system   configured language packs             if  (! $config [' App_multi_module '])  {//  If there is no   multi-module configuration                  lang::load (app_path .  ' Lang '  . DS .  $request->langset ()  . ext);              }        }         //  Get app scheduling information           $dispatch  = self:: $dispatch;//  default   empty          if  (Empty ($dispatch))  {            //   URL Routing detection              $dispatch  =  Self::routecheck ($request,  $config);//  get dispatch information              //    by   request     config   file          }        //  record current scheduling information           $request->dispatch ($dispatch);//  Configure scheduling   information          //  Logging Routing and request information  &Nbsp;      if  (self:: $debug)  {             log::record (' [ route ]  '  . var_export ($dispatch,  true),  ' info ');             log::record ( ' [ header ]  '  . var_export ($request->header (),  true),  ' info ');             log::record (' [ PARAM ]  '  . var_export ($request->param (),  true),  ' info ');         }        //  Monitoring app_begin         hook::listen (' App_begin ',  $dispatch);         switch  ($dispatch [' type '])  {             case  ' redirect ':                 //  Perform redirect Jump                   $data  =  Response::create ($dispatch [' url '],  ' redirect ')->code ($dispatch [' status ']);                 break;             case  ' module ':                 //  modules/Controllers/Operations                   $data  = self::module ($dispatch [' module '],   $config,  isset ($dispatch [' Convert '])  ?  $dispatch [' Convert '] : null);                 break;             case  ' Controller ':                 //  Performing controller Operations                   $data  = loader::action ($dispatch [' Controller ']);                 break;             case  ' method ':                 //  Execute callback method                   $data  = self::invokemethod ($ Dispatch[' method ']);                 break;            case  ' function ':                 //  execution Closures                   $data  = self::invokefunction ($dispatch [' function ']);                 break;            case  ' response ':                  $data  = $ dispatch[' response '];                 break;            default:                 throw new \ InvalidArgumentException (' Dispatch type not support ');         }   &nbsP;}  catch  (httpresponseexception  $exception)  {          $data  =  $exception->getresponse ();    }    //  Empties the instantiation of the Class     loader::clearinstance ();    //  output data to the client      if  ($data  instanceof response)  {          $response  =  $data;    } elseif  (!is_null ($data))  {         //  Default Auto-recognition response output type          $isAjax    =  $request->isajax ();         $type      =  $isAjax  ? config::get (' Default_ajax_return ')  : config :: Get (' Default_return_type ');         $response  = response:: Create ($data,  $type);    } else {         $response  =  response::create ();    }    //  Monitor app_end     hook::listen (' app_end ',  $response);    return  $response;}


This article is from the "Focus on PHP Group number: 414194301" blog, please be sure to keep this source http://jingshanls.blog.51cto.com/3357095/1860040

[Li Jingshan php] every day tp5-20161212| App.php-2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.