mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
取消自动加载中对composer包的支持
This commit is contained in:
@@ -71,7 +71,7 @@ www WEB部署目录(或者子目录)
|
||||
│ ├─mode 应用模式目录
|
||||
│ ├─tpl 系统模板目录
|
||||
│ ├─tests 单元测试文件目录
|
||||
│ ├─vendor 第三方类库目录(Composer依赖库)
|
||||
│ ├─vendor 第三方类库目录
|
||||
│ ├─base.php 基础定义文件
|
||||
│ ├─convention.php 框架惯例配置文件
|
||||
│ ├─helper.php 助手函数文件
|
||||
|
||||
@@ -22,12 +22,7 @@
|
||||
"sebastian/phpcpd": "*",
|
||||
"squizlabs/php_codesniffer": "2.*"
|
||||
},
|
||||
"config": {
|
||||
"vendor-dir": "vendor"
|
||||
},
|
||||
"extra": {
|
||||
"installer-paths": {
|
||||
"thinkphp": ["type:thinkphp-framework"]
|
||||
}
|
||||
"autoload": {
|
||||
"files": ["start.php"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,11 +49,6 @@ class Loader
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} elseif ($file = self::findFileInComposer($class)) {
|
||||
// Composer自动加载
|
||||
// 记录加载信息
|
||||
APP_DEBUG && self::$load[] = $file;
|
||||
include $file;
|
||||
} else {
|
||||
// 命名空间自动加载
|
||||
if (!strpos($class, '\\')) {
|
||||
@@ -122,95 +117,6 @@ class Loader
|
||||
{
|
||||
// 注册系统自动加载
|
||||
spl_autoload_register($autoload ? $autoload : 'think\\Loader::autoload');
|
||||
// 注册composer自动加载
|
||||
self::registerComposerLoader();
|
||||
}
|
||||
|
||||
// 注册composer自动加载
|
||||
private static function registerComposerLoader()
|
||||
{
|
||||
if (is_file(VENDOR_PATH . 'composer/autoload_namespaces.php')) {
|
||||
$map = require VENDOR_PATH . 'composer/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
self::$prefixesPsr0[$namespace[0]][$namespace] = (array) $path;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_file(VENDOR_PATH . 'composer/autoload_psr4.php')) {
|
||||
$map = require VENDOR_PATH . 'composer/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$length = strlen($namespace);
|
||||
if ('\\' !== $namespace[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
self::$prefixLengthsPsr4[$namespace[0]][$namespace] = $length;
|
||||
self::$prefixDirsPsr4[$namespace] = (array) $path;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_file(VENDOR_PATH . 'composer/autoload_classmap.php')) {
|
||||
$classMap = require VENDOR_PATH . 'composer/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
self::addMap($classMap);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_file(VENDOR_PATH . 'composer/autoload_files.php')) {
|
||||
$includeFiles = require VENDOR_PATH . 'composer/autoload_files.php';
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
self::composerRequire($fileIdentifier, $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function composerRequire($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static function findFileInComposer($class, $ext = '.php')
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DS) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset(self::$prefixLengthsPsr4[$first])) {
|
||||
foreach (self::$prefixLengthsPsr4[$first] as $prefix => $length) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach (self::$prefixDirsPsr4[$prefix] as $dir) {
|
||||
if (file_exists($file = $dir . DS . substr($logicalPathPsr4, $length))) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DS);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DS) . $ext;
|
||||
}
|
||||
|
||||
if (isset(self::$prefixesPsr0[$first])) {
|
||||
foreach (self::$prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DS . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remember that this class does not exist.
|
||||
return self::$map[$class] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user