|
Zhamao Framework 3.2.4
A high-performance chatbot + web framework
|
函数 | |
| if(function_exists( 'zm_internal_errcode')) | zm_dir (string $dir) |
| zm_exec (string $cmd) | |
| zm_sleep (float|int $time) | |
| zm_timer_tick (int $ms, callable $callback, int $times=0) | |
| zm_timer_after (int $ms, callable $callback) | |
| coroutine () | |
| zm_internal_errcode (int|string $code) | |
| zm_instance_id () | |
| logger () | |
| is_assoc_array (array $array) | |
| match_pattern (string $pattern, string $subject) | |
| match_args (string $pattern, string $subject) | |
| segment (string $type, array $data=[]) | |
| middleware () | |
| container () | |
| resolve (string $abstract, array $parameters=[]) | |
| db (string $name='') | |
| sql_builder (string $name='') | |
| zm_sqlite (string $name, bool $create_new=true, bool $keep_alive=true) | |
| zm_sqlite_builder (string $name, bool $create_new=true, bool $keep_alive=true) | |
| redis (string $name='default') | |
| config (array|string $key=null, mixed $default=null) | |
| bot (string $bot_id='', string $platform='') | |
| bot_connect (int $flag, int $fd) | |
| kv (string $name='') | |
| env (string $key, mixed $default=null) | |
| zm_http_response (int $status_code=200, ?string $reason=null, array $headers=[], mixed $body=null, string $protocol='1.1') | |
| ws_socket (int $flag=1) | |
| zm_create_app () | |
| zm_create_plugin () | |
| zm_websocket_client (string $address, array $header=[], mixed $set=null) | |
| bot | ( | string | $bot_id = '', |
| string | $platform = '' |
||
| ) |
| bot_connect | ( | int | $flag, |
| int | $fd | ||
| ) |
| config | ( | array|string | $key = null, |
| mixed | $default = null |
||
| ) |
获取 / 设置配置项
传入键名和(或)默认值,获取配置项 传入数组,设置配置项 不传参数,返回配置容器
| null | array | string | $key | 键名 |
| null | mixed | $default | 默认值 |
| container | ( | ) |
获取容器实例
| coroutine | ( | ) |
获取协程接口
| db | ( | string | $name = '' | ) |
获取 MySQL 调用的类
| DBException |
| env | ( | string | $key, |
| mixed | $default = null |
||
| ) |
获取环境变量
| is_assoc_array | ( | array | $array | ) |
判断传入的数组是否为关联数组
| kv | ( | string | $name = '' | ) |
获取一个 KV 库实例
| string | $name | KV 库名称 |
| logger | ( | ) |
助手方法,返回一个 Logger 实例
| match_args | ( | string | $pattern, |
| string | $subject | ||
| ) |
匹配参数
| match_pattern | ( | string | $pattern, |
| string | $subject | ||
| ) |
格式匹配
| middleware | ( | ) |
中间件操作类的助手函数
| redis | ( | string | $name = 'default' | ) |
获取 Redis 操作类
| string | $name | 使用的 Redis 连接名称 |
| resolve | ( | string | $abstract, |
| array | $parameters = [] |
||
| ) |
解析类实例(使用容器)
这是 {
@template T
| class-string<T> | $abstract |
| segment | ( | string | $type, |
| array | $data = [] |
||
| ) |
构建消息段的助手函数
| string | $type | 类型 |
| array | $data | 字段 |
| sql_builder | ( | string | $name = '' | ) |
获取构建 MySQL 的类
| DBException |
| ws_socket | ( | int | $flag = 1 | ) |
【助手函数】获取驱动的 WebSocket 服务器对应 Socket 操作对象
| int | $flag | 对应的 Server 端口标记 |
| Exception |
| zm_create_app | ( | ) |
创建炸毛框架应用
| zm_create_plugin | ( | ) |
创建炸毛框架的插件对象
| if(function_exists('zm_internal_errcode')) zm_dir | ( | string | $dir | ) |
根据具体操作系统替换目录分隔符
| string | $dir | 目录 |
| zm_exec | ( | string | $cmd | ) |
执行shell指令
| string | $cmd | 命令行 |
| zm_http_response | ( | int | $status_code = 200, |
| ?string | $reason = null, |
||
| array | $headers = [], |
||
| mixed | $body = null, |
||
| string | $protocol = '1.1' |
||
| ) |
【助手函数】HttpFactory 快速创建一个 Response
| int | $status_code | 状态码 |
| null | string | $reason | 原因(留空则使用状态码本身的) |
| array | $headers | 请求头 |
| mixed | $body | HTTP Body |
| string | $protocol | HTTP 协议版本 |
| zm_instance_id | ( | ) |
返回当前炸毛实例的 ID
| zm_internal_errcode | ( | int|string | $code | ) |
获取内部错误码
| zm_sleep | ( | float|int | $time | ) |
sleep 指定时间,单位为秒(最小单位为1毫秒,即0.001)
| zm_sqlite | ( | string | $name, |
| bool | $create_new = true, |
||
| bool | $keep_alive = true |
||
| ) |
获取一个便携 SQLite 操作类
| string | $name | 使用的 SQLite 连接文件名 |
| bool | $create_new | 是否在文件不存在时创建新的 |
| bool | $keep_alive | 是否维持 PDO 对象以便优化性能 |
| DBException |
| zm_sqlite_builder | ( | string | $name, |
| bool | $create_new = true, |
||
| bool | $keep_alive = true |
||
| ) |
获取便携 SQLite 操作类的 SQL 语句构造器
| string | $name | 使用的 SQLite 连接文件名 |
| bool | $create_new | 是否在文件不存在时创建新的 |
| bool | $keep_alive | 是否维持 PDO 对象以便优化性能 |
| DBException |
| zm_timer_after | ( | int | $ms, |
| callable | $callback | ||
| ) |
创建一个延后一次性计时器,只在指定毫秒后执行一次即销毁(Timer::after() 的别名)
| int | $ms | 时间(毫秒) |
| callable | $callback | 回调函数 |
| zm_timer_tick | ( | int | $ms, |
| callable | $callback, | ||
| int | $times = 0 |
||
| ) |
创建一个计时器(Timer::tick() 的别名)
| int | $ms | 时间(毫秒) |
| callable | $callback | 回调函数 |
| int | $times | 重复次数(如果为 0 或 -1,则永久循环,其他大于 0 的数为限定次数) |
| zm_websocket_client | ( | string | $address, |
| array | $header = [], |
||
| mixed | $set = null |
||
| ) |
创建一个 WebSocket 客户端
| string | $address | 接入地址,例如 ws://192.168.1.3:9998/ |
| array | $header | 请求头 |
| null | mixed | $set | Swoole 驱动下传入的额外参数 |
| DriverException | |
| ClientException |