Home >Backend Development >PHP Tutorial >In this case, ThinkPHP should import the third-party class library

In this case, ThinkPHP should import the third-party class library

WBOY
WBOYOriginal
2016-07-06 13:52:08963browse

命名空间与目录不一致导致无法引入GitElephant类库
In this case, ThinkPHP should import the third-party class library

回复内容:

命名空间与目录不一致导致无法引入GitElephant类库
In this case, ThinkPHP should import the third-party class library

最后这样解决了:

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

<code>// 注册特殊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; 
    }
});</code>

用import引入,或者直接require.

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn