降低控制器复杂度
我有个Volunteer(自愿者)控制器,下面有多个子模块,比如:job、question、resume、group
app
|--cli
|--m
|--web
| |--controller
| | |--Message.php
| | |--Passport.php
| | |--User.php
| | |--Volunteer.php
如果不分组,那么,所有子模块的操作(方法)都写到Volunteer这一个控制器里面,方法一多,就感觉很混乱
http://www.timophp.com/volunteer/jobList/
http://www.timophp.com/volunteer/jobDetail/
http://www.timophp.com/volunteer/jobPost/
http://www.timophp.com/volunteer/jobUpdate/
http://www.timophp.com/volunteer/questionPost/
http://www.timophp.com/volunteer/questionDetail/
app
|--cli
|--m
|--web
| |--controller
| | |--volunteer
| | | |--Job.php
| | | |--Group.php
| | | |--Question.php
| | | |--Resume.php
| | | |--Volunteer.php
| | |--Message.php
| | |--Passport.php
| | |--User.php
就分成了多个子控制器,相应的方法就分散到了子控制器,Volunteer控制器就显得很简洁,而且分组之后显得更清晰明了
http://api.timophp.com/volunteer/list
http://api.timophp.com/volunteer/job/find
http://api.timophp.com/volunteer/job/detail
http://api.timophp.com/volunteer/job/post
http://api.timophp.com/volunteer/job/update
http://api.timophp.com/volunteer/question/post
http://api.timophp.com/volunteer/question/detail
不需要配置,直接使用即可