执行下面的指令可以生成index模块的Blog控制器类库文件
>php think make:controller index/Blog
生成的控制器类文件如下:
<?phpnamespace app\index\controller;use think\Controller;use think\Request;class Blog extends Controller{ /**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{ //
} /**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{ //
} /**
* 保存新建的资源
*
* @param \think\Request $request
* @return \think\Response
*/
public function save(Request $request)
{ //
} /**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{ //
} /**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{ //
} /**
* 保存更新的资源
*
* @param \think\Request $request
* @param int $id
* @return \think\Response
*/
public function update(Request $request, $id)
{ //
} /**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{ //
}
}默认生成的控制器类继承\think\Controller ,并且生成了资源操作方法,如果仅仅生成空的控制器则可以使用:
>php think make:controller index\Blog --plain
执行下面的指令可以生成index模块的Blog模型类库文件
>php think make:model index/Blog
生成的模型类文件如下:
namespace app\index\model;
use think\Model;class Blog extends Model{
}