PHP Class think\App

Author: liu21st ([email protected])
Show file Open project: top-think/framework Class Usage Examples

Public Properties

Property Type Description
$debug 应用调试模式
$modulePath 当前模块路径
$namespace 应用类库命名空间
$suffix 应用类库后缀

Protected Properties

Property Type Description
$dispatch
$file
$init 是否初始化过
$routeCheck 应用路由检测
$routeMust 严格路由检测

Public Methods

Method Description
dispatch ( array | string $dispatch, string $type = 'module' ) : void 设置当前请求的调度信息
initCommon ( ) 初始化应用
invokeClass ( string $class, array $vars = [] ) : mixed 调用反射执行类的实例化 支持依赖注入
invokeFunction ( string | array | Closure $function, array $vars = [] ) : mixed 执行函数或者闭包方法 支持参数调用
invokeMethod ( string | array $method, array $vars = [] ) : mixed 调用反射执行类的方法 支持参数绑定
module ( array $result, array $config, boolean $convert = null ) : mixed 执行模块
route ( boolean $route, boolean $must = false ) : void 设置应用的路由检测机制
routeCheck ( think\Request $request, array $config ) : array URL路由检测(根据PATH_INFO)
run ( think\Request $request = null ) : Response 执行应用程序

Private Methods

Method Description
bindParams ( ReflectionMethod | ReflectionFunction $reflect, array $vars = [] ) : array 绑定参数
init ( string $module = '' ) : array 初始化应用或模块

Method Details

dispatch() public static method

设置当前请求的调度信息
public static dispatch ( array | string $dispatch, string $type = 'module' ) : void
$dispatch array | string 调度信息
$type string 调度类型
return void

initCommon() public static method

初始化应用
public static initCommon ( )

invokeClass() public static method

调用反射执行类的实例化 支持依赖注入
public static invokeClass ( string $class, array $vars = [] ) : mixed
$class string 类名
$vars array 变量
return mixed

invokeFunction() public static method

执行函数或者闭包方法 支持参数调用
public static invokeFunction ( string | array | Closure $function, array $vars = [] ) : mixed
$function string | array | Closure 函数或者闭包
$vars array 变量
return mixed

invokeMethod() public static method

调用反射执行类的方法 支持参数绑定
public static invokeMethod ( string | array $method, array $vars = [] ) : mixed
$method string | array 方法
$vars array 变量
return mixed

module() public static method

执行模块
public static module ( array $result, array $config, boolean $convert = null ) : mixed
$result array 模块/控制器/操作
$config array 配置参数
$convert boolean 是否自动转换控制器和操作名
return mixed

route() public static method

设置应用的路由检测机制
public static route ( boolean $route, boolean $must = false ) : void
$route boolean 是否需要检测路由
$must boolean 是否强制检测路由
return void

routeCheck() public static method

URL路由检测(根据PATH_INFO)
public static routeCheck ( think\Request $request, array $config ) : array
$request think\Request
$config array
return array

run() public static method

执行应用程序
public static run ( think\Request $request = null ) : Response
$request think\Request Request对象
return Response

Property Details

$debug public static property

应用调试模式
public static $debug

$dispatch protected static property

protected static $dispatch

$file protected static property

protected static $file

$init protected static property

是否初始化过
protected static $init

$modulePath public static property

当前模块路径
public static $modulePath

$namespace public static property

应用类库命名空间
public static $namespace

$routeCheck protected static property

应用路由检测
protected static $routeCheck

$routeMust protected static property

严格路由检测
protected static $routeMust

$suffix public static property

应用类库后缀
public static $suffix