\

Namespaces

App
Framework

Constants

APP_DEBUG

APP_DEBUG = \true

APP_ROOT

APP_ROOT = __DIR__

BASE_PATH

BASE_PATH = $base === false ? getcwd() : $base

BASE_PATH

BASE_PATH = \realpath(\dirname(__DIR__))

BASE_PATH

BASE_PATH = __DIR__

FRAMEWORK_VERSION

FRAMEWORK_VERSION = '0.2.2'

HEALTH_FILE

HEALTH_FILE = \LOG_DIR . '/health.json'

LOG_DIR

LOG_DIR = \APP_ROOT . '/storage/workerman'

MEMORY_CHECK_INTERVAL

MEMORY_CHECK_INTERVAL = 10

MEMORY_LIMIT_MB

MEMORY_LIMIT_MB = 256

Functions

APICsrfField()

APICsrfField() : string

返回 API 用的 CSRF Token 值.

Returns

string —

app()

app(null|string  $id = null, array  $params = []) : \ContainerInterface|object

获取容器或解析服务

Parameters

null|string $id

服务ID

array $params

可选构造参数

Returns

\ContainerInterface|object —

app_path()

app_path(string  $path = '') : string

Parameters

string $path

Returns

string —

base_path()

base_path(string  $path = '') : string

各路径辅助函数.

Parameters

string $path

Returns

string —

cache_clear()

cache_clear() : bool

Returns

bool —

cache_get()

cache_get(string  $key, mixed  $default = null) : mixed

Parameters

string $key
mixed $default

Returns

mixed —

cache_invalidate_tags()

cache_invalidate_tags(array  $tags) : bool

Parameters

array $tags

Returns

bool —

cache_set()

cache_set(string  $key, mixed  $value, ?int  $ttl = null, array  $tags = []) : bool

Parameters

string $key
mixed $value
?int $ttl
array $tags

Returns

bool —

caches()

caches(?string  $key = null, mixed  $value = '__GET__', ?int  $ttl = null) : mixed

Parameters

?string $key
mixed $value
?int $ttl

Returns

mixed —

caches_clear()

caches_clear() : bool

Returns

bool —

callHello()

callHello(string  $name) : string

开发辅助函数.

Parameters

string $name

Returns

string —

checkFilesChange()

checkFilesChange(array  $watchDirs, array  $lastMtimes) : bool

Parameters

array $watchDirs
array $lastMtimes

Returns

bool —

config()

config(?string  $key = null, mixed  $default = null) : mixed

配置项读取(支持点语法)

Parameters

?string $key
mixed $default

Returns

mixed —

config_path()

config_path(string  $path = '') : string

Parameters

string $path

Returns

string —

convert_to_symfony_request()

convert_to_symfony_request(\Workerman\Protocols\Http\Request  $request) : \Symfony\Component\HttpFoundation\Request

Parameters

\Workerman\Protocols\Http\Request $request

Returns

\Symfony\Component\HttpFoundation\Request —

convert_to_workerman_response()

convert_to_workerman_response(\Symfony\Component\HttpFoundation\Response  $res) : \Workerman\Protocols\Http\Response

Parameters

\Symfony\Component\HttpFoundation\Response $res

Returns

\Workerman\Protocols\Http\Response —

current_locale()

current_locale() : string

Returns

string —

database_path()

database_path(string  $path = '') : string

Parameters

string $path

Returns

string —

env()

env(string  $key, mixed  $default = null) : mixed

Parameters

string $key
mixed $default

Returns

mixed —

EventDispatch()

EventDispatch(object  $event) : object

事件分发函数.

Parameters

object $event

Returns

object —

generateRequestId()

generateRequestId() : string

Returns

string —

generateUuid()

generateUuid() : string

生成 UUID 和请求 ID.

Returns

string —

get_cache_instance()

get_cache_instance() : ?object

Returns

?object —

getCurrentUser()

getCurrentUser() : int

Returns

int —

getService()

getService(string  $id, array  $params = []) : object

从容器中获取服务(别名或类名).

Parameters

string $id
array $params

Returns

object —

getSymfonyStats()

getSymfonyStats() : mixed

Symfony组件加载统计脚本 使用 get_included_files() 和 get_declared_classes() 分析加载情况

Returns

mixed —

isWorkerProcess()

isWorkerProcess() : bool

Returns

bool —

log_info()

log_info(string  $msg) : void

Parameters

string $msg

printSymfonyStats()

printSymfonyStats(mixed  $stats) : mixed

Parameters

mixed $stats

Returns

mixed —

redirectToRoute()

redirectToRoute(string  $routeName, array  $parameters = [], int  $status = 302) : \Symfony\Component\HttpFoundation\RedirectResponse

根据路由名称生成 URL 并返回重定向响应.

Parameters

string $routeName
array $parameters
int $status

Throws

\InvalidArgumentException

Returns

\Symfony\Component\HttpFoundation\RedirectResponse —

renders()

renders(string  $template, array  $data = [], ?array  $exclude = null) : string

Parameters

string $template
array $data
?array $exclude

Returns

string —

rotate_logs()

rotate_logs() : void

startMonitorLoop()

startMonitorLoop(mixed  $watchDirs) : void

Parameters

mixed $watchDirs

startWorkerProcess()

startWorkerProcess() : mixed

Returns

mixed —

storage_path()

storage_path(string  $path = '') : string

Parameters

string $path

Returns

string —

ThinkValidate()

ThinkValidate(array  $data, array  $rule, array  $message = []) : array|true

Parameters

array $data
array $rule
array $message

Returns

array|true —

ThinkView()

ThinkView(string  $templateName, array  $data = []) : string

Think 模板渲染.

Parameters

string $templateName
array $data

Returns

string —

tpTemplateFormatDate()

tpTemplateFormatDate(int  $timestamp, string  $format = 'Y-m-d H:i:s') : string

自定义模板函数:格式化时间.

Parameters

int $timestamp
string $format

Returns

string —

tpTemplateHello()

tpTemplateHello(string  $name) : string

自定义模板函数:返回欢迎信息.

Parameters

string $name

Returns

string —

trans()

trans(string  $key, array  $parameters = []) : string

翻译服务.

Parameters

string $key
array $parameters

Returns

string —

update_health()

update_health() : void

validate()

validate(array  $data, array|string  $validate = '', array  $message = [], bool  $batch = false, bool  $failException = true) : bool

生成验证对象

Parameters

array $data

数据

array|string $validate

验证器类名或者验证规则数组

array $message

错误提示信息

bool $batch

是否批量验证

bool $failException

是否抛出异常

Returns

bool —

view()

view(string  $template, array  $data = []) : string

Parameters

string $template
array $data

Returns

string —

WebCsrfField()

WebCsrfField() : string

ThinTemplate 自动渲染中间件 CSRF token.

Returns

string —