Properties

$name

$name : string

路由标识

Type

string

$router

$router : \think\route\Route

路由对象

Type

\think\route\Route

$rule

$rule : mixed

路由规则

Type

mixed

$route

$route : string|\Closure

路由地址

Type

string|\Closure

$method

$method : string

请求类型

Type

string

$vars

$vars : array

路由变量

Type

array

$option

$option : array

路由参数

Type

array

$pattern

$pattern : array

路由变量规则

Type

array

$mergeOptions

$mergeOptions : array

需要和分组合并的路由参数

Type

array

$doAfter

$doAfter : boolean

是否需要后置操作

Type

boolean

$lockOption

$lockOption : boolean

是否锁定参数

Type

boolean

Methods

check()

check(  $request,   $url,   $completeMatch = false) 

Parameters

$request
$url
$completeMatch

getName()

getName() : string

获取Name

Returns

string

getRule()

getRule() : string

获取当前路由规则

Returns

string

getRoute()

getRoute() : mixed

获取当前路由地址

Returns

mixed

getMethod()

getMethod() : string

获取当前路由的请求类型

Returns

string

getVars()

getVars() : array

获取当前路由的变量

Returns

array

getRouter()

getRouter() : \think\route\Route

获取路由对象

Returns

\think\route\Route

doAfter()

doAfter() : boolean

路由是否有后置操作

Returns

boolean

getParent()

getParent() : \think\route\RuleGroup|null

获取路由分组

Returns

\think\route\RuleGroup|null

getDomain()

getDomain() : string

获取路由所在域名

Returns

string

getPattern()

getPattern(string  $name = '') : mixed

获取变量规则定义

Parameters

string $name

变量名

Returns

mixed

getConfig()

getConfig(string  $name = '') : mixed

获取路由参数

Parameters

string $name

变量名

Returns

mixed

getOption()

getOption(string  $name = '') : mixed

获取路由参数定义

Parameters

string $name

参数名

Returns

mixed

option()

option(string|array  $name, mixed  $value = '') : $this

注册路由参数

Parameters

string|array $name

参数名

mixed $value

Returns

$this

pattern()

pattern(string|array  $name, string  $rule = '') : $this

注册变量规则

Parameters

string|array $name

变量名

string $rule

变量规则

Returns

$this

name()

name(string  $name) : $this

设置标识

Parameters

string $name

标识名

Returns

$this

vars()

vars(array  $vars) : $this

设置变量

Parameters

array $vars

变量

Returns

$this

method()

method(string  $method) : $this

设置路由请求类型

Parameters

string $method

Returns

$this

before()

before(array|\Closure  $before) : $this

设置路由前置行为

Parameters

array|\Closure $before

Returns

$this

after()

after(array|\Closure  $after) : $this

设置路由后置行为

Parameters

array|\Closure $after

Returns

$this

ext()

ext(string  $ext = '') : $this

检查后缀

Parameters

string $ext

Returns

$this

denyExt()

denyExt(string  $ext = '') : $this

检查禁止后缀

Parameters

string $ext

Returns

$this

domain()

domain(string  $domain) : $this

检查域名

Parameters

string $domain

Returns

$this

filter()

filter(string|array  $name, mixed  $value = null) : $this

设置参数过滤检查

Parameters

string|array $name
mixed $value

Returns

$this

model()

model(array|string  $var, string|\Closure  $model = null, boolean  $exception = true) : $this

绑定模型

Parameters

array|string $var

路由变量名 多个使用 & 分割

string|\Closure $model

绑定模型类

boolean $exception

是否抛出异常

Returns

$this

append()

append(array  $append = array()) : $this

附加路由隐式参数

Parameters

array $append

Returns

$this

validate()

validate(mixed  $validate, string  $scene = null, array  $message = array(), boolean  $batch = false) : $this

绑定验证

Parameters

mixed $validate

验证器类

string $scene

验证场景

array $message

验证提示

boolean $batch

批量验证

Returns

$this

response()

response(mixed  $response) : $this

绑定Response对象

Parameters

mixed $response

Returns

$this

header()

header(  $header, string  $value = null) : $this

设置Response Header信息

Parameters

$header
string $value

参数值

Returns

$this

middleware()

middleware(string|array|\Closure  $middleware, mixed  $param = null) : $this

指定路由中间件

Parameters

string|array|\Closure $middleware
mixed $param

Returns

$this

cache()

cache(array|string  $cache) : $this

设置路由缓存

Parameters

array|string $cache

Returns

$this

depr()

depr(boolean  $depr) : $this

检查URL分隔符

Parameters

boolean $depr

Returns

$this

mergeExtraVars()

mergeExtraVars(boolean  $merge = true) : $this

是否合并额外参数

Parameters

boolean $merge

Returns

$this

mergeOptions()

mergeOptions(array  $option = array()) : $this

设置需要合并的路由参数

Parameters

array $option

Returns

$this

https()

https(boolean  $https = true) : $this

检查是否为HTTPS请求

Parameters

boolean $https

Returns

$this

ajax()

ajax(boolean  $ajax = true) : $this

检查是否为AJAX请求

Parameters

boolean $ajax

Returns

$this

pjax()

pjax(boolean  $pjax = true) : $this

检查是否为PJAX请求

Parameters

boolean $pjax

Returns

$this

mobile()

mobile(boolean  $mobile = true) : $this

检查是否为手机访问

Parameters

boolean $mobile

Returns

$this

view()

view(boolean|array  $view = true) : $this

当前路由到一个模板地址 当使用数组的时候可以传入模板变量

Parameters

boolean|array $view

Returns

$this

redirect()

redirect(boolean  $redirect = true) : $this

当前路由为重定向

Parameters

boolean $redirect

是否为重定向

Returns

$this

completeMatch()

completeMatch(boolean  $match = true) : $this

设置路由完整匹配

Parameters

boolean $match

Returns

$this

removeSlash()

removeSlash(boolean  $remove = true) : $this

是否去除URL最后的斜线

Parameters

boolean $remove

Returns

$this

allowCrossDomain()

allowCrossDomain(boolean  $allow = true, array  $header = array()) : $this

设置是否允许跨域

Parameters

boolean $allow
array $header

Returns

$this

crossDomainRule()

crossDomainRule() : $this

设置路由规则全局有效

Returns

$this

mergeGroupOptions()

mergeGroupOptions() : array

合并分组参数

Returns

array

parseRule()

parseRule(\think\Request  $request, string  $rule, string  $route, string  $url, array  $option = array(), array  $matches = array()) : \think\route\Dispatch

解析匹配到的规则路由

Parameters

\think\Request $request

请求对象

string $rule

路由规则

string $route

路由地址

string $url

URL地址

array $option

路由参数

array $matches

匹配的变量

Returns

\think\route\Dispatch

parseUrlPath()

parseUrlPath(string  $url) : array

解析URL的pathinfo参数和变量

Parameters

string $url

URL地址

Returns

array

__call()

__call(string  $method, array  $args) : $this

设置路由参数

Parameters

string $method

方法名

array $args

调用参数

Returns

$this

__sleep()

__sleep() 

__wakeup()

__wakeup() 

__debugInfo()

__debugInfo() 

checkCrossDomain()

checkCrossDomain(\think\Request  $request) : \think\route\Dispatch|void

检查OPTIONS请求

Parameters

\think\Request $request

Returns

\think\route\Dispatch|void

checkBefore()

checkBefore(mixed  $before) : mixed

检查路由前置行为

Parameters

mixed $before

前置行为

Returns

mixed

dispatch()

dispatch(\think\Request  $request, mixed  $route, array  $option) : \think\route\Dispatch

发起路由调度

Parameters

\think\Request $request

Request对象

mixed $route

路由地址

array $option

路由参数

Returns

\think\route\Dispatch

dispatchMethod()

dispatchMethod(\think\Request  $request, string  $route) : \think\route\dispatch\Callback

解析URL地址为 模块/控制器/操作

Parameters

\think\Request $request

Request对象

string $route

路由地址

Returns

\think\route\dispatch\Callback

dispatchController()

dispatchController(\think\Request  $request, string  $route) : \think\route\dispatch\Controller

解析URL地址为 模块/控制器/操作

Parameters

\think\Request $request

Request对象

string $route

路由地址

Returns

\think\route\dispatch\Controller

dispatchModule()

dispatchModule(\think\Request  $request, string  $route) : \think\route\dispatch\Module

解析URL地址为 模块/控制器/操作

Parameters

\think\Request $request

Request对象

string $route

路由地址

Returns

\think\route\dispatch\Module

checkOption()

checkOption(array  $option, \think\Request  $request) : boolean

路由检查

Parameters

array $option

路由参数

\think\Request $request

Request对象

Returns

boolean

parseUrlParams()

parseUrlParams(\think\Request  $request,   $url, array  $var = array()) : void

解析URL地址中的参数Request对象

Parameters

\think\Request $request
$url
array $var

变量

buildRuleRegex()

buildRuleRegex(string  $rule, array  $match, array  $pattern = array(), array  $option = array(), boolean  $completeMatch = false, string  $suffix = '') : string

生成路由的正则规则

Parameters

string $rule

路由规则

array $match

匹配的变量

array $pattern

路由变量规则

array $option

路由参数

boolean $completeMatch

路由是否完全匹配

string $suffix

路由正则变量后缀

Returns

string

buildNameRegex()

buildNameRegex(string  $name, string  $pattern, string  $suffix) : string

生成路由变量的正则规则

Parameters

string $name

路由变量

string $pattern

变量规则

string $suffix

路由正则变量后缀

Returns

string

parseVar()

parseVar(string  $rule) : array

分析路由规则中的变量

Parameters

string $rule

路由规则

Returns

array