Constants

VERSION

VERSION = '5.1.11'

Properties

$modulePath

$modulePath : string

当前模块路径

Type

string

$debug

$debug : boolean

应用调试模式

Type

boolean

$beginTime

$beginTime : float

应用开始时间

Type

float

$beginMem

$beginMem : integer

应用内存初始占用

Type

integer

$namespace

$namespace : string

应用类库命名空间

Type

string

$suffix

$suffix : boolean

应用类库后缀

Type

boolean

$routeMust

$routeMust : boolean

严格路由检测

Type

boolean

$appPath

$appPath : string

应用类库目录

Type

string

$thinkPath

$thinkPath : string

框架目录

Type

string

$rootPath

$rootPath : string

应用根目录

Type

string

$runtimePath

$runtimePath : string

运行时目录

Type

string

$configPath

$configPath : string

配置目录

Type

string

$routePath

$routePath : string

路由目录

Type

string

$configExt

$configExt : string

配置后缀

Type

string

$container

$container : \think\Container

容器对象实例

Type

\think\Container

$bind

$bind : string

绑定模块(控制器)

Type

string

Methods

__construct()

__construct(  $appPath = '') 

Parameters

$appPath

bind()

bind(string  $bind) : $this

绑定模块或者控制器

Parameters

string $bind

Returns

$this

path()

path(string  $path) : $this

设置应用类库目录

Parameters

string $path

路径

Returns

$this

initialize()

initialize() : void

初始化应用

init()

init(string  $module = '') : void

初始化应用或模块

Parameters

string $module

模块名

run()

run() : \think\Response

执行应用程序

Throws

\think\Exception

Returns

\think\Response

dispatch()

dispatch(\think\route\Dispatch  $dispatch) : $this

设置当前请求的调度信息

Parameters

\think\route\Dispatch $dispatch

调度信息

Returns

$this

log()

log(mixed  $msg, string  $type = 'info') : void

记录调试信息

Parameters

mixed $msg

调试信息

string $type

信息类型

config()

config(string  $name = '') : mixed

获取配置参数 为空则获取所有配置

Parameters

string $name

配置参数名(支持二级配置 .号分割)

Returns

mixed

routeCheck()

routeCheck() : \think\route\Dispatch

URL路由检测(根据PATH_INFO)

Returns

\think\route\Dispatch

routeMust()

routeMust(boolean  $must = false) : $this

设置应用的路由检测机制

Parameters

boolean $must

是否强制检测路由

Returns

$this

create()

create(string  $name, string  $layer, boolean  $appendSuffix = false, string  $common = 'common') : object

实例化应用类库

Parameters

string $name

类名称

string $layer

业务层名称

boolean $appendSuffix

是否添加类名后缀

string $common

公共模块名

Throws

\think\exception\ClassNotFoundException

Returns

object

model()

model(string  $name = '', string  $layer = 'model', boolean  $appendSuffix = false, string  $common = 'common') : \think\Model

实例化(分层)模型

Parameters

string $name

Model名称

string $layer

业务层名称

boolean $appendSuffix

是否添加类名后缀

string $common

公共模块名

Throws

\think\exception\ClassNotFoundException

Returns

\think\Model

controller()

controller(string  $name, string  $layer = 'controller', boolean  $appendSuffix = false, string  $empty = '') : object

实例化(分层)控制器 格式:[模块名/]控制器名

Parameters

string $name

资源地址

string $layer

控制层名称

boolean $appendSuffix

是否添加类名后缀

string $empty

空控制器名称

Throws

\think\exception\ClassNotFoundException

Returns

object

validate()

validate(string  $name = '', string  $layer = 'validate', boolean  $appendSuffix = false, string  $common = 'common') : \think\Validate

实例化验证类 格式:[模块名/]验证器名

Parameters

string $name

资源地址

string $layer

验证层名称

boolean $appendSuffix

是否添加类名后缀

string $common

公共模块名

Throws

\think\exception\ClassNotFoundException

Returns

\think\Validate

db()

db(mixed  $config = array(), boolean|string  $name = false) : \think\db\Query

数据库初始化

Parameters

mixed $config

数据库配置

boolean|string $name

连接标识 true 强制重新连接

Returns

\think\db\Query

action()

action(string  $url, string|array  $vars = array(), string  $layer = 'controller', boolean  $appendSuffix = false) : mixed

远程调用模块的操作方法 参数格式 [模块/控制器/]操作

Parameters

string $url

调用地址

string|array $vars

调用参数 支持字符串和数组

string $layer

要调用的控制层名称

boolean $appendSuffix

是否添加类名后缀

Throws

\think\exception\ClassNotFoundException

Returns

mixed

parseClass()

parseClass(string  $module, string  $layer, string  $name, boolean  $appendSuffix = false) : string

解析应用类的类名

Parameters

string $module

模块名

string $layer

层名 controller model ...

string $name

类名

boolean $appendSuffix

Returns

string

version()

version() : string

获取框架版本

Returns

string

isDebug()

isDebug() : boolean

是否为调试模式

Returns

boolean

getModulePath()

getModulePath() : string

获取模块路径

Returns

string

setModulePath()

setModulePath(string  $path) : void

设置模块路径

Parameters

string $path

路径

getRootPath()

getRootPath() : string

获取应用根目录

Returns

string

getAppPath()

getAppPath() : string

获取应用类库目录

Returns

string

getRuntimePath()

getRuntimePath() : string

获取应用运行时目录

Returns

string

getThinkPath()

getThinkPath() : string

获取核心框架目录

Returns

string

getRoutePath()

getRoutePath() : string

获取路由目录

Returns

string

getConfigPath()

getConfigPath() : string

获取应用配置目录

Returns

string

getConfigExt()

getConfigExt() : string

获取配置后缀

Returns

string

getNamespace()

getNamespace() : string

获取应用类库命名空间

Returns

string

setNamespace()

setNamespace(string  $namespace) : $this

设置应用类库命名空间

Parameters

string $namespace

命名空间名称

Returns

$this

getSuffix()

getSuffix() : boolean

是否启用类库后缀

Returns

boolean

getBeginTime()

getBeginTime() : float

获取应用开启时间

Returns

float

getBeginMem()

getBeginMem() : integer

获取应用初始内存占用

Returns

integer

container()

container() : \think\Container

获取容器实例

Returns

\think\Container

__set()

__set(  $name,   $value) 

Parameters

$name
$value

__get()

__get(  $name) 

Parameters

$name

__isset()

__isset(  $name) 

Parameters

$name

__unset()

__unset(  $name) 

Parameters

$name

offsetExists()

offsetExists(  $key) 

Parameters

$key

offsetGet()

offsetGet(  $key) 

Parameters

$key

offsetSet()

offsetSet(  $key,   $value) 

Parameters

$key
$value

offsetUnset()

offsetUnset(  $key) 

Parameters

$key

loadLangPack()

loadLangPack() 

parseModuleAndClass()

parseModuleAndClass(string  $name, string  $layer, boolean  $appendSuffix) : array

解析模块和类名

Parameters

string $name

资源地址

string $layer

验证层名称

boolean $appendSuffix

是否添加类名后缀

Returns

array