mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
定义系统类库映射文件alias.php
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | Author: liu21st <liu21st@gmail.com>
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// $Id$
|
|
||||||
namespace Think;
|
namespace Think;
|
||||||
use Think\Config;
|
use Think\Config;
|
||||||
|
|
||||||
@@ -21,11 +20,11 @@ class Loader {
|
|||||||
'Vendor' => VENDOR_PATH,
|
'Vendor' => VENDOR_PATH,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// 自动加载
|
||||||
static public function autoload($class){
|
static public function autoload($class){
|
||||||
// 检查是否定义classmap
|
// 检查是否定义classmap
|
||||||
if(isset(self::$map[$class])) {
|
if(isset(self::$map[$class])) {
|
||||||
include self::$map[$class];
|
include self::$map[$class];
|
||||||
return ;
|
|
||||||
}else{ // 命名空间自动加载
|
}else{ // 命名空间自动加载
|
||||||
$find = false;
|
$find = false;
|
||||||
foreach (self::$namespace as $name=>$path){
|
foreach (self::$namespace as $name=>$path){
|
||||||
@@ -38,23 +37,8 @@ class Loader {
|
|||||||
$filename = $path.str_replace('\\','/',$class).'.php';
|
$filename = $path.str_replace('\\','/',$class).'.php';
|
||||||
if(is_file($filename)) {
|
if(is_file($filename)) {
|
||||||
include $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
|
// 注册classmap
|
||||||
@@ -72,6 +56,7 @@ class Loader {
|
|||||||
self::$map = array_merge(self::$map,$map);
|
self::$map = array_merge(self::$map,$map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 注册自动加载机制
|
||||||
static public function register($autoload=''){
|
static public function register($autoload=''){
|
||||||
spl_autoload_register($autoload?$autoload:['Think\Loader','autoload']);
|
spl_autoload_register($autoload?$autoload:['Think\Loader','autoload']);
|
||||||
}
|
}
|
||||||
@@ -225,19 +210,20 @@ class Loader {
|
|||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
static public function instance($class,$method='') {
|
static public function instance($class,$method='') {
|
||||||
|
static $_instance = [];
|
||||||
$identify = $class.$method;
|
$identify = $class.$method;
|
||||||
if(!isset(self::$_instance[$identify])) {
|
if(!isset($_instance[$identify])) {
|
||||||
if(class_exists($class)){
|
if(class_exists($class)){
|
||||||
$o = new $class();
|
$o = new $class();
|
||||||
if(!empty($method) && method_exists($o,$method))
|
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
|
else
|
||||||
self::$_instance[$identify] = $o;
|
$_instance[$identify] = $o;
|
||||||
}
|
}
|
||||||
else
|
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
|
* @access public
|
||||||
* @param string $log 日志信息
|
* @param string $log 日志信息
|
||||||
* @param string $level 日志级别
|
|
||||||
* @param string $destination 写入目标
|
* @param string $destination 写入目标
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|||||||
46
alias.php
46
alias.php
@@ -8,25 +8,33 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | Author: liu21st <liu21st@gmail.com>
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// $Id$
|
|
||||||
|
|
||||||
return array(/*
|
// 系统类库映射定义
|
||||||
'Think\App' => CORE_PATH.'app.php',
|
return array(
|
||||||
'Think\Log' => CORE_PATH.'log.php',
|
'Think\App' => CORE_PATH.'App.php',
|
||||||
'Think\Config' => CORE_PATH.'config.php',
|
'Think\Log' => CORE_PATH.'Log.php',
|
||||||
'Think\Route' => CORE_PATH.'route.php',
|
'Think\Log\Driver\File' => CORE_PATH.'Log\Driver\File.php',
|
||||||
'Think\Exception'=> CORE_PATH.'exception.php',
|
'Think\Config' => CORE_PATH.'Config.php',
|
||||||
'Think\Model' => CORE_PATH.'model.php',
|
'Think\Route' => CORE_PATH.'Route.php',
|
||||||
'Think\Db' => CORE_PATH.'db.php',
|
'Think\Exception'=> CORE_PATH.'Exception.php',
|
||||||
'Think\Template' => CORE_PATH.'template.php',
|
'Think\Model' => CORE_PATH.'Model.php',
|
||||||
'Think\Error' => CORE_PATH.'error.php',
|
'Think\Db' => CORE_PATH.'Db.php',
|
||||||
'Think\Cache' => CORE_PATH.'cache.php',
|
'Think\Db\Driver' => CORE_PATH.'Db\Driver.php',
|
||||||
'Think\Tag' => CORE_PATH.'tag.php',
|
'Think\Template' => CORE_PATH.'Template.php',
|
||||||
'Think\Session' => CORE_PATH.'session.php',
|
'Think\Error' => CORE_PATH.'Error.php',
|
||||||
'Think\Cookie' => CORE_PATH.'cookie.php',
|
'Think\Cache' => CORE_PATH.'Cache.php',
|
||||||
'Think\Controll' => CORE_PATH.'controll.php',
|
'Think\Tag' => CORE_PATH.'Tag.php',
|
||||||
'Think\View' => CORE_PATH.'view.php',
|
'Think\Session' => CORE_PATH.'Session.php',
|
||||||
'Think\Auth' => CORE_PATH.'auth.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\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