mirror of
https://gitee.com/ShopeX/OMS
synced 2026-03-23 02:45:33 +08:00
64 lines
1.4 KiB
PHP
64 lines
1.4 KiB
PHP
<?php
|
||
/**
|
||
* Copyright © ShopeX (http://www.shopex.cn). All rights reserved.
|
||
* See LICENSE file for license details.
|
||
*/
|
||
|
||
// 定义根目录
|
||
define('__ROOT_DIR', dirname(__FILE__) . '/../');
|
||
|
||
/**
|
||
* 类库自动加载
|
||
*
|
||
* @param string $class_name
|
||
* @return boolean
|
||
*/
|
||
function __autoloadOMS($class_name) {
|
||
|
||
if (stripos($class_name, 'PhpAmqpLib') !== false) {
|
||
|
||
return __autoloadAmqpLib($class_name);
|
||
}
|
||
|
||
$pos = strpos($class_name, '_');
|
||
|
||
if ($pos) {
|
||
$owner = substr($class_name, 0, $pos);
|
||
$class_name = substr($class_name, $pos + 1);
|
||
|
||
$path = __ROOT_DIR . 'lib/' . str_replace('_', '/', $class_name) . '.php';
|
||
|
||
if (file_exists($path)) {
|
||
|
||
return require_once $path;
|
||
} else {
|
||
|
||
return false;
|
||
}
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
function __autoloadAmqpLib($class_name) {
|
||
|
||
$filename = __ROOT_DIR . 'lib/third/' . str_replace("\\", '/', $class_name) . '.php';
|
||
if (file_exists($filename)) {
|
||
|
||
return require_once $filename;
|
||
} else {
|
||
|
||
return false;
|
||
}
|
||
}
|
||
|
||
//注册类文件自动引用
|
||
if(function_exists('spl_autoload_register')){
|
||
spl_autoload_register('__autoloadOMS');
|
||
}else{
|
||
die('Can not register autoload function !!!');
|
||
}
|
||
|
||
//加载配置文件
|
||
require_once(__ROOT_DIR . 'config/config.php'); |