Register composer Auto-load private static function registercomposerloader () {// default no if (Is_file (vendor_path . ' composer/autoload_namespaces.php ')) { $map = require VENDOR_PATH . ' Composer/autoload_namespaces.php '; foreach ($map as $namespace => $path) { self::addpsr0 ($namespace, $path); } }// load Namespaces if (is_file (vendor_path . ' composer/ autoload_psr4.php ') { $map = require vendor_path . ' composer/autoload_psr4.php '; foreach ($map as $namespace => $path)  {            SELF::ADDPSR4 ($namespace, $path); } }// load Psr4 Standard if (is_file (vendor_path . ' Composer/autoload_ classmap.php ') { $classMap = require vendor_path . ' composer/autoload_classmap.php '; if ($CLASSMAP) { self:: Addclassmap ($CLASSMAP); } }// load classmap if (Is_file (vendor_path . ' composer/autoload_files.php ')) { $includeFiles = require vendor_path . ' composer/autoload_files.php '; foreach ($includeFiles as $fileIdentifier => $file) { if (empty (Self:: $autoloadFiles [$fileIdentifier])) { __ Require_file ($file); self:: $autoloadFiles [$fileIdentifier] = true; } } }// loading File}/** * Import the required class libraries import with Java This function has caching capabilities * @param string $class Class Library namespace string * @param string $baseUrl Start path * @param string $ext imported file extensions * @return boolean */public static function import ($class, $baseUrl = ", $ext = ext ) {// import class files static $_file = [];// static files warehouses $key = $class . $ baseurl;// key file $class = str_replace (['. ', ' # '], [ds, '. '], $class);//Handling class if (Isset ($_file[$key)) { return true; }// if has been loaded This file, is directly if (empty ($ BASEURL) {// If the start path is empty, is the default value list ($name, $ Class) = explode (ds, $class, 2);// return previous two arrays if (iSset (self:: $PREFIXDIRSPSR 4[$name . ' \ \ ')) {// If there is this Psr4 // Registered Namespaces $baseUrl = self:: $PREFIXDIRSPSR 4[$name . ' \ \ ']; } elseif (' @ ' == $name) { //loading the current module Application class library $baseUrl = app:: $modulePath;// get @ Way } elseif (Is_dir (extend_path . $name)) { $baseUrl = EXTEND_PATH;// Get Base Address } else { // Loading Libraries $BASEURL of other modules = APP_PATH . $name . DS; } } elseif (substr ($BASEURL, -1) != ds) { $baseUrl .= DS; }// Get baseUrl // Import class library files if (Is_array ($BASEURL)) {//if the class exists If base address is baseUrl foreach ($baseUrl as $path) { $filename = $path . DS . $class . $ext;// baseurl if (Is_file ($filename)) { break;// found file on exit } } } else { $filename = $baseUrl . $ class . $ext; }// get filename if (!empty ($filename) && is_file ($filename) {// if no file, If you have this file // Open debug mode, the win environment is strictly case sensitive if (Is_win && pathinfo ($filename, pathinfo_filename) != pathinfo (Realpath ($filename), pathinfo_filename)) { return false; }// If path no &Nbsp; __include_file ($filename);// loading files $_file[$key] = true;// execution status return true; } return false;}
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/1859059
[Li Jingshan php] every day tp5-20161206| Loader.php-4