PHP Class phprs\Invoker

Author: caoym
Show file Open project: caoym/phprs-restful Class Usage Examples

Public Properties

Property Type Description
$method_name

Public Methods

Method Description
__construct ( Container $ins, string $method )
__invoke ( Request $request, Response &$response ) 执行API
bind ( integer $id, string $type, $param ) 绑定参数,返回值,异常
check ( ) 检查参数是否均已经绑定
getBindParamPos ( ) : array 获取被绑定的参数列表 返回的是参数位置
getClassName ( ) : string
getContainer ( ) : object
getMethodName ( ) : string
getParams ( ) 绑定的参数
getReturns ( ) 绑定的返回值
getThrows ( ) 绑定的异常

Method Details

__construct() public method

public __construct ( Container $ins, string $method )
$ins Container 被调用的实例容器
$method string 被调用的实例方法

__invoke() public method

执行API
public __invoke ( Request $request, Response &$response )
$request Request 请求
$response Response 响应

bind() public method

绑定参数,返回值,异常
public bind ( integer $id, string $type, $param )
$id integer 参数id
$type string 绑定类型 param/return/throws
$param param: [['arg_name'=>'$._SERVER.REQUEST_URI'],...] [[参数名=>jsonpath表达式],...] 指定api接口参数从http请求中获取的方式 returns: 指定哪些参数被作为返回值 [ ['status','200 OK'], 200 OK 作为常量, 输出到status ['cookie','$arg0'], $arg0变量输出到cookie ['body'], 未指定变量, 则取返回值输出 ] throws 指定根据不同的异常设置响应信息 [ ['MyException','status' , '404 Not Found'], ['MyException','body','$msg'], ['Exception','status','500 Internal Server Error'], ]

check() public method

检查参数是否均已经绑定
public check ( )

getBindParamPos() public method

获取被绑定的参数列表 返回的是参数位置
public getBindParamPos ( ) : array
return array

getClassName() public method

public getClassName ( ) : string
return string

getContainer() public method

public getContainer ( ) : object
return object

getMethodName() public method

public getMethodName ( ) : string
return string

getParams() public method

绑定的参数
public getParams ( )

getReturns() public method

绑定的返回值
public getReturns ( )

getThrows() public method

绑定的异常
public getThrows ( )

Property Details

$method_name public property

public $method_name