首页 > ThinkPHP在这种情况下该如果导入第三方类库

ThinkPHP在这种情况下该如果导入第三方类库

命名空间与目录不一致导致无法引入GitElephant类库


最后这样解决了:

下载地址:http://www.opencmf.cn

// 注册特殊autoload
spl_autoload_register(function ($class) {
    $path = APP_PATH . "Git/Util/";
    $filename = $path . str_replace('\\', '/', $class) . '.php';
    if (is_file($filename)) {
        // Win环境下面严格区分大小写
        if (IS_WIN && false === strpos(str_replace('/', '\\', realpath($filename)), $class . '.php')) {
            return;
        }
        include $filename;
    }
    if (file_exists($filename)) { 
        require_once $filename; 
    }
});

定义alias配置文件。
这个可以实现配置文件路径和命名空间的指向问题。
http://document.thinkphp.cn/manual_3_2.html#autoload
可以看类库映射这个小节。


用import引入,或者直接require.

【热门文章】
【热门文章】