tp5.1 RESTful风格简要介绍及route.php路由设定

第一步:创建方法类。

        tp5.1 RESTful风格简要介绍及route.php路由设定

 

第二步:找到根目录下的route文件夹,打开route.php文件

tp5.1 RESTful风格简要介绍及route.php路由设定

tp5.1 RESTful风格简要介绍及route.php路由设定

第三步:在文件中添加php语句:Route::rule('lesson/:data/:captcha_sign','parentport/Lesson/add_lesson_msg','GET');

tp5.1 RESTful风格简要介绍及route.php路由设定

其中:lesson:接口名称

           data、captcha_sign:请求参数

           parentport/Lesson/add_lesson_msg:模块名/类名/方法名

           GET:请求方式

第四步:访问域名http://www.bendi.com/lesson/成功/123

tp5.1 RESTful风格简要介绍及route.php路由设定

 

注意:在RESTful风格中,有最常用的四种请求方式,即:POST、GET、DELETE、PUT

           POST:一般对应数据库添加操作以及无数据库操作接口;

           GET:一般对应数据库查询操作;

           DELETE:一般对应数据库删除操作;

           PUT:一般对应数据库修改操作;