mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
定义系统类库映射文件alias.php
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// $Id$
|
||||
namespace Think;
|
||||
use Think\Config;
|
||||
|
||||
@@ -21,11 +20,11 @@ class Loader {
|
||||
'Vendor' => VENDOR_PATH,
|
||||
];
|
||||
|
||||
// 自动加载
|
||||
static public function autoload($class){
|
||||
// 检查是否定义classmap
|
||||
if(isset(self::$map[$class])) {
|
||||
include self::$map[$class];
|
||||
return ;
|
||||
}else{ // 命名空间自动加载
|
||||
$find = false;
|
||||
foreach (self::$namespace as $name=>$path){
|
||||
@@ -38,23 +37,8 @@ class Loader {
|
||||
$filename = $path.str_replace('\\','/',$class).'.php';
|
||||
if(is_file($filename)) {
|
||||
include $filename;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
// 扫描模块目录
|
||||
/*
|
||||
//if(defined(\MODULE_PATH)) {
|
||||
$dir = glob(MODULE_PATH.'*');
|
||||
foreach ($dir as $path){
|
||||
if(false === strpos($path,'.') && $pos = strripos($class,basename($path))) {
|
||||
$name = parse_name(substr($class,0,$pos));
|
||||
if(is_file($path.'/'.$name.EXT)) {
|
||||
include $path.'/'.$name.EXT;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
}
|
||||
//}*/
|
||||
}
|
||||
|
||||
// 注册classmap
|
||||
@@ -72,6 +56,7 @@ class Loader {
|
||||
self::$map = array_merge(self::$map,$map);
|
||||
}
|
||||
|
||||
// 注册自动加载机制
|
||||
static public function register($autoload=''){
|
||||
spl_autoload_register($autoload?$autoload:['Think\Loader','autoload']);
|
||||
}
|
||||
@@ -225,19 +210,20 @@ class Loader {
|
||||
* @return object
|
||||
*/
|
||||
static public function instance($class,$method='') {
|
||||
static $_instance = [];
|
||||
$identify = $class.$method;
|
||||
if(!isset(self::$_instance[$identify])) {
|
||||
if(!isset($_instance[$identify])) {
|
||||
if(class_exists($class)){
|
||||
$o = new $class();
|
||||
if(!empty($method) && method_exists($o,$method))
|
||||
self::$_instance[$identify] = call_user_func_array(array(&$o, $method));
|
||||
$_instance[$identify] = call_user_func_array(array(&$o, $method));
|
||||
else
|
||||
self::$_instance[$identify] = $o;
|
||||
$_instance[$identify] = $o;
|
||||
}
|
||||
else
|
||||
E(Lang::get('_CLASS_NOT_EXIST_').':'.$class);
|
||||
E('_CLASS_NOT_EXIST_:'.$class);
|
||||
}
|
||||
return self::$_instance[$identify];
|
||||
return $_instance[$identify];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,10 +25,9 @@ class File {
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志直接写入
|
||||
* 日志写入接口
|
||||
* @access public
|
||||
* @param string $log 日志信息
|
||||
* @param string $level 日志级别
|
||||
* @param string $destination 写入目标
|
||||
* @return void
|
||||
*/
|
||||
|
||||
46
alias.php
46
alias.php
@@ -8,25 +8,33 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// $Id$
|
||||
|
||||
return array(/*
|
||||
'Think\App' => CORE_PATH.'app.php',
|
||||
'Think\Log' => CORE_PATH.'log.php',
|
||||
'Think\Config' => CORE_PATH.'config.php',
|
||||
'Think\Route' => CORE_PATH.'route.php',
|
||||
'Think\Exception'=> CORE_PATH.'exception.php',
|
||||
'Think\Model' => CORE_PATH.'model.php',
|
||||
'Think\Db' => CORE_PATH.'db.php',
|
||||
'Think\Template' => CORE_PATH.'template.php',
|
||||
'Think\Error' => CORE_PATH.'error.php',
|
||||
'Think\Cache' => CORE_PATH.'cache.php',
|
||||
'Think\Tag' => CORE_PATH.'tag.php',
|
||||
'Think\Session' => CORE_PATH.'session.php',
|
||||
'Think\Cookie' => CORE_PATH.'cookie.php',
|
||||
'Think\Controll' => CORE_PATH.'controll.php',
|
||||
'Think\View' => CORE_PATH.'view.php',
|
||||
'Think\Auth' => CORE_PATH.'auth.php',
|
||||
// 系统类库映射定义
|
||||
return array(
|
||||
'Think\App' => CORE_PATH.'App.php',
|
||||
'Think\Log' => CORE_PATH.'Log.php',
|
||||
'Think\Log\Driver\File' => CORE_PATH.'Log\Driver\File.php',
|
||||
'Think\Config' => CORE_PATH.'Config.php',
|
||||
'Think\Route' => CORE_PATH.'Route.php',
|
||||
'Think\Exception'=> CORE_PATH.'Exception.php',
|
||||
'Think\Model' => CORE_PATH.'Model.php',
|
||||
'Think\Db' => CORE_PATH.'Db.php',
|
||||
'Think\Db\Driver' => CORE_PATH.'Db\Driver.php',
|
||||
'Think\Template' => CORE_PATH.'Template.php',
|
||||
'Think\Error' => CORE_PATH.'Error.php',
|
||||
'Think\Cache' => CORE_PATH.'Cache.php',
|
||||
'Think\Tag' => CORE_PATH.'Tag.php',
|
||||
'Think\Session' => CORE_PATH.'Session.php',
|
||||
'Think\Cookie' => CORE_PATH.'Cookie.php',
|
||||
'Think\Controller' => CORE_PATH.'Controller.php',
|
||||
'Think\View' => CORE_PATH.'View.php',
|
||||
'Think\Url' => CORE_PATH.'url.php',
|
||||
'Think\Verify' => CORE_PATH.'verify.php',*/
|
||||
'Think\Verify' => CORE_PATH.'Verify.php',
|
||||
'Think\Debug' => CORE_PATH.'Debug.php',
|
||||
'Think\Input' => CORE_PATH.'Input.php',
|
||||
'Think\Parser' => CORE_PATH.'Parser.php',
|
||||
'Think\Lang' => CORE_PATH.'Lang.php',
|
||||
'Think\Filter' => CORE_PATH.'Filter.php',
|
||||
'Think\Oauth' => CORE_PATH.'Oauth.php',
|
||||
'Think\Rest' => CORE_PATH.'Rest.php',
|
||||
);
|
||||
Reference in New Issue
Block a user