diff --git a/README.md b/README.md index 5169fcca..9aad07b9 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ www WEB部署目录(或者子目录) │ ├─mode 应用模式目录 │ ├─tpl 系统模板目录 │ ├─tests 单元测试文件目录 -│ ├─vendor 第三方类库目录(Composer依赖库) +│ ├─vendor 第三方类库目录 │ ├─base.php 基础定义文件 │ ├─convention.php 框架惯例配置文件 │ ├─helper.php 助手函数文件 diff --git a/composer.json b/composer.json index f7c736a4..5d8f4d10 100644 --- a/composer.json +++ b/composer.json @@ -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"] } } diff --git a/library/think/Loader.php b/library/think/Loader.php index beb4b4f8..c52d3b9c 100644 --- a/library/think/Loader.php +++ b/library/think/Loader.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; } /**