Properties

$layout

$layout : string

布局模板

Type

string

$noNeedLogin

$noNeedLogin : array

无需登录的方法,同时也就不需要鉴权了.

Type

array

$noNeedRight

$noNeedRight : array

无需鉴权的方法,但需要登录.

Type

array

$view

$view : \think\View

Type

\think\View — 视图类实例

$request

$request : \think\Request

Type

\think\Request — Request 实例

$failException

$failException : boolean

Type

boolean — 验证失败是否抛出异常

$batchValidate

$batchValidate : boolean

Type

boolean — 是否批量验证

$beforeActionList

$beforeActionList : array

Type

array — 前置操作方法列表

Methods

_initialize()

_initialize() 

初始化操作

__construct()

__construct(\think\Request  $request = null) 

构造方法

Parameters

\think\Request $request

Request 对象

index()

index() 

view()

view() 

loadlang()

loadlang(string  $name) 

加载语言文件.

Parameters

string $name

assignconfig()

assignconfig(mixed  $name, mixed  $value = '') 

渲染配置信息.

Parameters

mixed $name

键名或数组

mixed $value

beforeAction()

beforeAction(string  $method, array  $options = array()) : void

前置操作

Parameters

string $method

前置操作方法名

array $options

调用参数 ['only'=>[...]] 或者 ['except'=>[...]]

fetch()

fetch(string  $template = '', array  $vars = array(), array  $replace = array(), array  $config = array()) : mixed

加载模板输出

Parameters

string $template

模板文件名

array $vars

模板输出变量

array $replace

模板替换

array $config

模板参数

Returns

mixed

display()

display(string  $content = '', array  $vars = array(), array  $replace = array(), array  $config = array()) : mixed

渲染内容输出

Parameters

string $content

模板内容

array $vars

模板输出变量

array $replace

替换内容

array $config

模板参数

Returns

mixed

assign()

assign(mixed  $name, mixed  $value = '') : $this

模板变量赋值

Parameters

mixed $name

要显示的模板变量

mixed $value

变量的值

Returns

$this

engine()

engine(array|string  $engine) : $this

初始化模板引擎

Parameters

array|string $engine

引擎参数

Returns

$this

validateFailException()

validateFailException(boolean  $fail = true) : $this

设置验证失败后是否抛出异常

Parameters

boolean $fail

是否抛出异常

Returns

$this

validate()

validate(array  $data, string|array  $validate, array  $message = array(), boolean  $batch = false, mixed  $callback = null) : array|string|true

验证数据

Parameters

array $data

数据

string|array $validate

验证器名或者验证规则数组

array $message

提示信息

boolean $batch

是否批量验证

mixed $callback

回调方法(闭包)

Throws

\think\exception\ValidateException

Returns

array|string|true

success()

success(mixed  $msg = '', string  $url = null, mixed  $data = '', integer  $wait = 3, array  $header = array()) : void

操作成功跳转的快捷方法

Parameters

mixed $msg

提示信息

string $url

跳转的 URL 地址

mixed $data

返回的数据

integer $wait

跳转等待时间

array $header

发送的 Header 信息

Throws

\think\exception\HttpResponseException

error()

error(mixed  $msg = '', string  $url = null, mixed  $data = '', integer  $wait = 3, array  $header = array()) : void

操作错误跳转的快捷方法

Parameters

mixed $msg

提示信息

string $url

跳转的 URL 地址

mixed $data

返回的数据

integer $wait

跳转等待时间

array $header

发送的 Header 信息

Throws

\think\exception\HttpResponseException

result()

result(mixed  $data, integer  $code, mixed  $msg = '', string  $type = '', array  $header = array()) : void

返回封装后的 API 数据到客户端

Parameters

mixed $data

要返回的数据

integer $code

返回的 code

mixed $msg

提示信息

string $type

返回数据格式

array $header

发送的 Header 信息

Throws

\think\exception\HttpResponseException

redirect()

redirect(string  $url, array|integer  $params = array(), integer  $code = 302, array  $with = array()) : void

URL 重定向

Parameters

string $url

跳转的 URL 表达式

array|integer $params

其它 URL 参数

integer $code

http code

array $with

隐式传参

Throws

\think\exception\HttpResponseException

getResponseType()

getResponseType() : string

获取当前的 response 输出类型

Returns

string