controller定义了与文件名相同的类名,渲染输出使用return输出'ming','ming'=>'xiao');返回json($数据);}}此时页面渲染json文件,不能打断controller中的代码。.使用暂停输出'ming','ming'=>'晓');halt("输出测试");返回json($数据);}}使用halt直接在命名空间5,'name'=>'ming']));返回$id;}}定义Index命名空间下的子控制器Blog目录结构定义路由规则request->action();$path=$this->app->getBasePath();变量转储($动作);变量转储($路径);}/***显示创建资源表单页面。**@return\think\Response*/publicfunctioncreate(){//}/***保存新创建的资源**@param\think\Request$request*@return\think\Response*/publicfunctionsave(Request$request){//}/***显示指定资源**@paramint$id*@return\think\Response*/publicfunctionread($id){//}/***显示编辑资源表单页面。**@paramint$id*@return\think\Response*/publicfunctionedit($id){//}/***保存更新的资源**@param\think\Request$request*@paramint$id*@return\think\Response*/publicfunctionupdate(请求$request,$id){//}/***删除指定资源**@paramint$id*@return\think\Response*/publicfunctiondelete($id){//}}输出内容字符串(5)"index"string(43)"/home/ming/PhpstormProjects/untitled12/app/"控制器验证validate(['name'=>'thinkphp','email'=>'thinkphp@qq.com',],'app\index\validate\User');}catch(ValidateException$e){//输出错误信息dump($e->得到错误());}}/***显示创建资源表单页面。**@return\think\Response*/publicfunctioncreate(){//}/***保存新创建的资源**@param\think\Request$request*@return\think\Response*/publicfunctionsave(Request$request){//}/***显示指定资源**@paramint$id*@return\think\Response*/publicfunctionread($id){//}/***显示编辑资源表单页面。**@paramint$id*@return\think\Response*/publicfunctionedit($id){//}/***保存更新的资源**@param\think\Request$request*@paramint$id*@return\think\Response*/publicfunctionupdate(Request$request,$id){//}/***删除指定资源**@paramint$id*@return\think\Response*/publicfunctiondelete($id){//}}以便控制器验证空控制器找不到方法时调用空控制器方法publicfunction__call($name,$arguments){//TODO:实施__call()方法。返回“错误请求”;}Resourcecontrollercreaterestfulcontrollerinputphpthinkmake:controllerindex@Bloggenerateresourcecontrollergenerateapihello='ming';返回$next($request);}}用路由注册控制器middleware([app\index\middleware\Hello::class]);访问http://localhost:8082/index/ming出现ming,说明中间件注册成功
