-
Notifications
You must be signed in to change notification settings - Fork 0
Route
axios edited this page Oct 13, 2020
·
2 revisions
The path to the configuration file of
Route
isPath::config()/routes.php
.
- path
- the path info of request, must be start with '/'
- use
{:<arg-name>}
to set param in path - use
**
to ingore string before next '/' - ignore all strings from
***
- method
- the method of request
- handler
- combine with
<module>/<controller>/<action>
,index/index/index
for example
- combine with
- intro
- the information of route
<?php
# routes.php
return [
[
'path' => '/', // request path info
'method' => 'get|post', // request method
'handler' => 'index/index/index', // <module>/<controller>/<action>
'intro' => 'homepage', // optional, intro of route
],
[
'path' => '/test/{:id}/{:title}/foo/{:bar}', // with params
'method' => 'all', // match all request method
'handler' => 'index/index/index',
'intro' => 'has param',
],
[
'path' => '/has/**/text/{:name}', // ** : ingore string before next '/'
'method' => 'post',
'handler' => 'index/index/index',
'intro' => 'ignore part of path',
],
[
'path' => '/admin/***', // *** : ignore string
'method' => 'all',
'handler' => 'index/index/illegal',
'intro' => 'default route rule',
],
[
'path' => '/***', // *** : ignore string
'method' => 'all',
'handler' => 'index/index/notFound',
'intro' => 'the default route rule when none of the above rules are matched',
]
];
Anything unclear or inaccurate? Please let me know at axioscros@aliyun.com