Properties

$__useCount

$__useCount : integer

Type

integer — 作用计数

$__genTime

$__genTime : integer

Type

integer — 创建时间

$__isContruct

$__isContruct : boolean

Type

boolean — 是否执行构造方法

$stdClass

$stdClass : \stdClass|null

Type

\stdClass|null — 对象模板

$codes

$codes : array

Type

array — HTTP状态码

$response

$response : \swoole_http_response

Type

\swoole_http_response — HTTP响应对象

$request

$request : \swoole_http_request

Type

\swoole_http_request — HTTP请求对象

$__isDestroy

$__isDestroy : boolean

Type

boolean — 销毁标志

$redisPools

$redisPools : array

Type

array — redis连接池

$mysqlPools

$mysqlPools : array

Type

array — mysql连接池

$redisProxies

$redisProxies : array

Type

array — redis代理池

$reflections

$reflections : array

Type

array — 反射类属性的默认值

Methods

__construct()

__construct(\PG\MSF\Controllers\Controller  $controller) 

构造方法

Parameters

\PG\MSF\Controllers\Controller $controller

控制器实例

__sleep()

__sleep() : array

属性用于序列化

Returns

array

__unsleep()

__unsleep() 

和__sleep作用相反

getServerInstance()

getServerInstance() : \swoole_server

获取运行Server实例

Returns

\swoole_server

getConfig()

getConfig() : \Noodlehaus\Config

获取运行server实例配置对象

Returns

\Noodlehaus\Config

getPack()

getPack() : \PG\MSF\Pack\IPack

获取运行server实例打包对象

Returns

\PG\MSF\Pack\IPack

getRedisPool()

getRedisPool(string  $poolName) : boolean|\PG\AOP\Wrapper|\PG\MSF\Pools\CoroutineRedisProxy|\Redis

获取Redis连接池

Parameters

string $poolName

配置的Redis连接池名称

Returns

boolean|\PG\AOP\Wrapper|\PG\MSF\Pools\CoroutineRedisProxy|\Redis

getMysqlPool()

getMysqlPool(string  $poolName) : boolean|\PG\AOP\Wrapper

获取MySQL连接池

Parameters

string $poolName

配置的MySQL连接池名称

Returns

boolean|\PG\AOP\Wrapper

getRedisProxy()

getRedisProxy(string  $proxyName) : boolean|\PG\AOP\Wrapper|\PG\MSF\Pools\CoroutineRedisProxy|\Redis

获取Redis代理

Parameters

string $proxyName

配置的Redis代理名称

Throws

\Exception

Returns

boolean|\PG\AOP\Wrapper|\PG\MSF\Pools\CoroutineRedisProxy|\Redis

setRedisPools()

setRedisPools(array|null  $redisPools) : $this

设置RedisPools

Parameters

array|null $redisPools

多个Redis连接池实例,通常用于销毁Redis连接池,赋值为NULL

Returns

$this

setRedisProxies()

setRedisProxies(array|null  $redisProxies) : $this

设置RedisPools

Parameters

array|null $redisProxies

多个Redis代理实例,通常用于销毁Redis代理,赋值为NULL

Returns

$this

destroy()

destroy() 

销毁,解除引用

isUse()

isUse() 

对象已使用标识

getIsDestroy()

getIsDestroy() : boolean

是否已经执行destroy

Returns

boolean

setContext()

setContext(\PG\MSF\Helpers\Context  $context) : $this

设置上下文

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

Returns

$this

set()

set(\swoole_http_request  $request, \swoole_http_response|null  $response = null) : $this

设置HTTP请求和HTTP响应对象

Parameters

\swoole_http_request $request

HTTP请求对象

\swoole_http_response|null $response

HTTP请求响应对象

Returns

$this

setStatusHeader()

setStatusHeader(integer  $code = 200) : $this

设置HTTP响应状态码

Parameters

integer $code

HTTP状态码

Returns

$this

setContentType()

setContentType(string  $mime_type) : $this

设置响应的Content-Type报头

Parameters

string $mime_type

Content-Type的值,如application/json;charset=utf-8

Returns

$this

setHeader()

setHeader(string  $key, string  $value) : $this

设置响应的其他HTTP报头

Parameters

string $key

HTTP报头Key

string $value

HTTP报头Value

Returns

$this

setCookie()

setCookie(string  $key, string  $value = '', integer  $expire, string  $path = '/', string  $domain = '', boolean  $secure = false, boolean  $httponly = false) : $this

设置HTTP响应的cookie信息,与PHP的setcookie()参数一致

Parameters

string $key

Cookie名称

string $value

Cookie值

integer $expire

有效时间

string $path

有效路径

string $domain

有效域名

boolean $secure

Cookie是否仅仅通过安全的HTTPS连接传给客户端

boolean $httponly

设置成TRUE,Cookie仅可通过HTTP协议访问

Returns

$this

output()

output(mixed|null  $data = null, integer  $status = 200) 

响应原始数据

Parameters

mixed|null $data

响应数据

integer $status

响应HTTP状态码

outputJson()

outputJson(mixed|null  $data = null, integer  $status = 200) 

响应json格式数据

Parameters

mixed|null $data

响应数据

integer $status

响应HTTP状态码

outputView()

outputView(array  $data, string|null  $view = null) 

通过模板引擎响应输出HTML

Parameters

array $data

待渲染KV数据

string|null $view

文件名

Throws

\Exception
\Throwable
\Exception

end()

end(string  $output = '', boolean  $gzip = true) 

结束HTTP请求,发送响应体

Parameters

string $output

发送的数据

boolean $gzip

是否启用gzip压缩