# \PG\MSF\BaseOutput

Class Output

## Summary

Methods
Properties
Constants
__construct()
__sleep()
__unsleep()
getServerInstance()
getConfig()
getPack()
getRedisPool()
getMysqlPool()
getRedisProxy()
setRedisPools()
setRedisProxies()
destroy()
isUse()
getIsDestroy()
setContext()
set()
setStatusHeader()
setContentType()
setHeader()
setCookie()
output()
outputJson()
outputView()
end()
$__useCount
$__genTime
$__isContruct
$stdClass
$codes
$response
$request
No constants found
No protected methods found
$__isDestroy
$redisPools
$mysqlPools
$redisProxies
$reflections
$controller
N/A
No private methods found
No private properties found
N/A

File
  Base/Output.php
Package
  MSF\Base
Class hierarchy
  \PG\MSF\Base\Child
  \PG\MSF\Base\Core
  \PG\MSF\Base\Output

## Tags

None found

## Properties

### $__useCount

    $__useCount : integer

#### Type

integer — 作用计数

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $__genTime

    $__genTime : integer

#### Type

integer — 创建时间

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $__isContruct

    $__isContruct : boolean

#### Type

boolean — 是否执行构造方法

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $stdClass

    $stdClass : \stdClass|null

#### Type

\stdClass|null — 对象模板

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $codes

    $codes : array

#### Type

array — HTTP状态码

#

See also
  https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

## Tags

None found

### $response

    $response : \swoole_http_response

#### Type

\swoole_http_response — HTTP响应对象

#

## Tags

None found

### $request

    $request : \swoole_http_request

#### Type

\swoole_http_request — HTTP请求对象

#

## Tags

None found

### $__isDestroy

    $__isDestroy : boolean

#### Type

boolean — 销毁标志

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $redisPools

    $redisPools : array

#### Type

array — redis连接池

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $mysqlPools

    $mysqlPools : array

#### Type

array — mysql连接池

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $redisProxies

    $redisProxies : array

#### Type

array — redis代理池

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $reflections

    $reflections : array

#### Type

array — 反射类属性的默认值

#

Inherited from
  \PG\MSF\Base\Child

## Tags

None found

### $controller

    $controller : \PG\MSF\Controllers\Controller

#### Type

\PG\MSF\Controllers\Controller — 当前处理请求的控制器

#

## Tags

None found

## Methods

### __construct()

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

构造方法

#### Parameters

\PG\MSF\Controllers\Controller | $controller | 控制器实例

#

## Tags

None found

### __sleep()

    __sleep() : array

属性用于序列化

#### Returns

array

#

## Tags

None found

### __unsleep()

    __unsleep()

和__sleep作用相反

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### getServerInstance()

    getServerInstance() : \swoole_server

获取运行Server实例

#### Returns

\swoole_server

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### getConfig()

    getConfig() : \Noodlehaus\Config

获取运行server实例配置对象

#### Returns

\Noodlehaus\Config

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### getPack()

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

获取运行server实例打包对象

#### Returns

\PG\MSF\Pack\IPack

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### 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

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### getMysqlPool()

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

获取MySQL连接池

#### Parameters

string | $poolName | 配置的MySQL连接池名称

#### Returns

boolean|\PG\AOP\Wrapper

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### 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

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### setRedisPools()

    setRedisPools(array|null  $redisPools) : $this

设置RedisPools

#### Parameters

array|null | $redisPools | 多个Redis连接池实例，通常用于销毁Redis连接池，赋值为NULL

#### Returns

$this

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### setRedisProxies()

    setRedisProxies(array|null  $redisProxies) : $this

设置RedisPools

#### Parameters

array|null | $redisProxies | 多个Redis代理实例，通常用于销毁Redis代理，赋值为NULL

#### Returns

$this

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### destroy()

    destroy()

销毁,解除引用

#

## Tags

None found

### isUse()

    isUse()

对象已使用标识

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### getIsDestroy()

    getIsDestroy() : boolean

是否已经执行destroy

#### Returns

boolean

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### setContext()

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

设置上下文

#### Parameters

\PG\MSF\Helpers\Context | $context | 请求上下文对象

#### Returns

$this

#

Inherited from
  \PG\MSF\Base\Child

## Tags

None found

### 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

#

## Tags

None found

### setStatusHeader()

    setStatusHeader(integer  $code = 200) : $this

设置HTTP响应状态码

#### Parameters

integer | $code | HTTP状态码

#### Returns

$this

#

## Tags

None found

### setContentType()

    setContentType(string  $mime_type) : $this

设置响应的Content-Type报头

#### Parameters

string | $mime_type | Content-Type的值，如application/json;charset=utf-8

#### Returns

$this

#

## Tags

None found

### setHeader()

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

设置响应的其他HTTP报头

#### Parameters

string | $key | HTTP报头Key
string | $value | HTTP报头Value

#### Returns

$this

#

## Tags

None found

### 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

#

## Tags

None found

### output()

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

响应原始数据

#### Parameters

mixed|null | $data | 响应数据
integer | $status | 响应HTTP状态码

#

## Tags

None found

### outputJson()

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

响应json格式数据

#### Parameters

mixed|null | $data | 响应数据
integer | $status | 响应HTTP状态码

#

## Tags

None found

### outputView()

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

通过模板引擎响应输出HTML

#### Parameters

array | $data | 待渲染KV数据
string|null | $view | 文件名

#### Throws

\Exception
\Throwable
\Exception

#

## Tags

None found

### end()

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

结束HTTP请求，发送响应体

#### Parameters

string | $output | 发送的数据
boolean | $gzip | 是否启用gzip压缩

#

## Tags

None found

### Output.php