firecms-ext / utils
hyperf 扩展:常用工具函数
Installs: 615
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/firecms-ext/utils
Requires
- php: >=8.0
- ezyang/htmlpurifier: ^4.14
- hyperf/amqp: ~2.2.0
- hyperf/cache: ~v2.0
- hyperf/config: ^2.2
- hyperf/constants: ~2.2.0
- hyperf/crontab: ^2.2
- hyperf/db-connection: ^2.2
- hyperf/di: ~v2.0
- hyperf/framework: ~v2.0
- hyperf/http-message: ~v2.0
- hyperf/http-server: ~v2.0
- hyperf/logger: ~2.2.0
- hyperf/model-cache: ^2.2
- hyperf/redis: ~v2.0
- hyperf/resource: ^2.2
- hyperf/rpc-client: ^2.2
- hyperf/snowflake: v2.2.33.1
- hyperf/utils: ~v2.0
- hyperf/validation: ^2.2
- nesbot/carbon: ^2.62
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: >=7.0
- qiutuleng/hyperf-dump-server: ^1.2
- swoole/ide-helper: ^4.5
Suggests
- swow/swow: Required to create swow components.
This package is auto-updated.
Last update: 2026-02-11 10:32:27 UTC
README
# 依赖安装
composer require firecms-ext/utils
函数列表
# Cache 对象
function cache(): CacheInterface;
# Redis 对象
function redis(): Redis;
# 生成主键
function generateId(): string;
# 计算年龄
function age(string $birthday): int;
# 生成 uuid
function uuid(string $prefix = ''): string;
# 文件大小格式化
function filesizeFormat(int $filesize): string;
# array 转 tree
function toTree(array $rows, string $pid = 'parent_id', string $id = 'id', string $children = 'children'): array;
# 普通 tree 转 tree 下拉选项
function treeToOptions(array $tree, string $label = 'title', string $value = 'id', string $children = 'children'): array;
# 下拉选项
function options(array $rows, ?string $label = 'title', ?string $value = 'id'): array;
# 分组下拉选项
function groupOptions(array $groups, ?string $label = 'title', ?string $value = 'id'): array;
# 净化 HTML 字符串
function purifyHtml(string $html, HTMLPurifier_Config $config = null): string;