1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace Mall\Framework\Core;
- class AutoLoad
- {
- static function _autoLoad($class)
- {
- //var_dump($class);
- //xssCheck();
- if(function_exists('apcu_fetch') && ini_get('apc.enabled')){
- if ($file_path = apcu_fetch('autoload_'.PROJECT_DOMAIN.$class)) {
- loadFile($file_path);
- return true;
- }
- }
- $class_path = str_replace('\\', '/', $class) . '.Class.php';
- // util工具类特殊处理
- if(strpos($class_path, 'Util') === 0){
- $real_path = DS.$class_path;
- }else{
- $real_path = substr($class_path, strpos($class_path, '/'));
- }
- switch($real_path){
- case strpos($class_path, FRAMEWORK_NAME.'/') !== FALSE:
- $file_path = ROOT_PATH . $real_path;
- break;
- case strpos($class_path, 'Smarty') !== FALSE:
- return false;
- break;
- case strpos($class_path, 'Service') !== FALSE:
- if(!defined('SWOOLESERVER_NAME')){
- throw new \Exception('请去swoole服务项目启动脚本配置服务目录名称,重启生效!!!');
- }
- $file_path = ROOT_PATH . DS . '..' . DS . SWOOLESERVER_NAME . $real_path;
- break;
- default:
- $file_path = PROJECT_PATH . $real_path;
- }
- if(function_exists('apcu_fetch') && ini_get('apc.enabled')){
- apcu_add('autoload_'.PROJECT_DOMAIN.$class, $file_path);
- }
- loadFile($file_path);
- }
- }
|