加载中...

快捷路由


快捷路由允许你快速给控制器注册路由,并且针对不同的请求类型可以设置方法前缀,例如:

  1. // 给User控制器设置快捷路由
  2. Route::controller('user','index/User');

User控制器定义如下:

  1. namespace app\index\controller;
  2. class User {
  3. public function getInfo()
  4. {
  5. }
  6. public function getPhone()
  7. {
  8. }
  9. public function postInfo()
  10. {
  11. }
  12. public function putInfo()
  13. {
  14. }
  15. public function deleteInfo()
  16. {
  17. }
  18. }

我们可以通过下面的URL访问

  1. get http://localhost/user/info
  2. get http://localhost/user/phone
  3. post http://localhost/user/info
  4. put http://localhost/user/info
  5. delete http://localhost/user/info

还没有评论.