Route binding method
Bind to controller/operation
Bind the current URL to the controller/operation, up to the operation level is supported , for example, add in the routing definition file:
// 绑定当前的URL到 Blog控制器 Route::bind('blog'); // 绑定当前的URL到 Blog控制器的read操作 Route::bind('blog/read');
This method is valid for routing to controller/operation. If we bind to the blog controller, then the original access URL can be from
http://serverName/blog/read/id/5
Simplified to
http://serverName/read/id/5
If the route
Route::get('blog/:id','blog/read');
is defined, then the access URL becomes
http://serverName/5
Bound to the namespace
Bind the current URL to a specified namespace, for example:
// 绑定命名空间 Route::bind(':\app\index\controller');
Then, we only need to directly access \app\index through
http://serverName/blog/read/id/5
\controller\Blog class read method.
Bind to class
Bind the current URL directly to a specified class, for example:
// 绑定到类 Route::bind('\app\index\controller\Blog');
Then, Next, we only need to directly access the read method of the \app\index\controller\Blog class through
http://serverName/read/id/5
.