命名空间与目录不一致导致无法引入gitelephant类库
命名空间与目录不一致导致无法引入gitelephant类库
最后这样解决了:
下载地址: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.
立即学习“PHP免费学习笔记(深入)”;
定义alias配置文件。
这个可以实现配置文件路径和命名空间的指向问题。
http://document.thinkphp.cn/manual_3_2.html#autoload
可以看类库映射这个小节。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号