快捷路由允许你快速给控制器注册路由,并且针对不同的请求类型可以设置方法前缀,例如:
// 给User控制器设置快捷路由
Route::controller('user','index/User');
User控制器定义如下:
namespace app\index\controller;
class User {
public function getInfo()
{
}
public function getPhone()
{
}
public function postInfo()
{
}
public function putInfo()
{
}
public function deleteInfo()
{
}
}
我们可以通过下面的URL访问
get http://localhost/user/info
get http://localhost/user/phone
post http://localhost/user/info
put http://localhost/user/info
delete http://localhost/user/info