最近开始学习TP5框架。尝试着做一个简单的数据表的添加插入查询删除操作。测试访问出现错误:模块不存在:user。
错误信息: HttpException in App.php line 347
// 模块初始化
if ($module && $available) {
// 初始化模块
$request->module($module);
$config = self::init($module);
} else {
throw new HttpException(404, 'module not exists:' . $module); //此处标出
}
} else {
// 单一模块部署
$module = '';
$request->module($module);
}
我先在application/index/model
目录下新建了user模型,代码如下。
<?php
namespace app\index\model;
use think\Model;
class User extends Model{
protected $table = 'User';
protected $pk = 'ID';
}
Controller里建立了相应控制器:
<?php
namespace app\index\controller;
use think\Request;
use think\controller\Rest;
use app\index\model\users;
class User extend Rest{
......
public function add(){
return 'hello';
}
......
}
修改了route.php:
use think\Route;
......
Route::any('user','index/Users/add');
路径匹配问题