Test.php代码如下:
namespace test;
class Test
{
public function hello(){
return "hello";
}
} 然后我在public/index.php的最后使用:\think\Loader::addNamespace('test',LIB_PATH.'test/');
\think\Loader::addClassMap('test\Test',LIB_PATH.'test\Test.php');之后在index模块下的TestIndex控制器下,测试,代码如下:namespace app\index\controller;
use think\Controller;
use test\Test;
class TestIndex extends Controller
{
public function phello(){
$obj = new Test();
return $obj->hello();
}
}但浏览器仍然报错: Class 'test\Test' not found 请问我该怎么定义类库映射呢?
最佳答案