lacus/utils
Composer 安装命令:
composer require lacus/utils
包简介
Reusable utilities library for Lacus Solutions' packages (type description, HTML escaping, random sequences)
README 文档
README
A PHP reusable utilities library for Lacus Solutions' packages.
| Passing ✔ | Passing ✔ | Passing ✔ | Passing ✔ | Passing ✔ |
Features
- Type description: Human-readable type strings for error messages (primitives, arrays,
NaN,Infinity) - HTML escaping: Escape
&,<,>,",'for safe output and XSS mitigation - Random sequences: Generate numeric, alphabetic, or alphanumeric sequences of any length
- URI encoding: Percent-encode/decode URI components (path, query, fragment) per RFC 3986
- Zero dependencies: No production dependencies
Installation
composer require lacus/utils
Quick Start
<?php use Lacus\Utils\HtmlUtils; use Lacus\Utils\SequenceGenerator; use Lacus\Utils\SequenceType; use Lacus\Utils\TypeDescriber; use Lacus\Utils\UrlUtils; TypeDescriber::describe(null); // 'null' TypeDescriber::describe('hello'); // 'string' TypeDescriber::describe(42); // 'integer number' TypeDescriber::describe([1, 2, 3]); // 'number[]' HtmlUtils::escape('Tom & Jerry'); // 'Tom & Jerry' HtmlUtils::unescape('Tom & Jerry'); // 'Tom & Jerry' SequenceGenerator::generate(10, SequenceType::Numeric); // e.g. '9956000611' SequenceGenerator::generate(6, SequenceType::Alphabetic); // e.g. 'AXQMZB' UrlUtils::encodeUriComponent('a b'); // 'a%20b' UrlUtils::decodeUriComponent('a%20b'); // 'a b'
API
All classes live under the Lacus\Utils namespace.
| Class | Method | Description |
|---|---|---|
TypeDescriber |
describe(mixed $value): string |
Type description for error messages |
HtmlUtils |
escape, unescape |
HTML entity escaping and decoding |
SequenceGenerator |
generate(int $size, SequenceType $type): string |
Random sequence generation |
SequenceType |
enum: Numeric, Alphabetic, Alphanumeric |
Sequence kind |
UrlUtils |
encodeUriComponent, decodeUriComponent |
URI component percent-encoding (RFC 3986) |
TypeDescriber::describe()
Same behaviour as JS describeType: null, string, boolean, integer number, float number, NaN, Infinity, Array (empty), number[], (number | string)[], object, resource, etc.
HtmlUtils
- escape(string $value): string — Escapes HTML special characters:
&→&,<→<,>→>,"→",'→'. Use for safe output and XSS mitigation. - unescape(string $value): string — Decodes those entities (reverse of
escape). Use only on previously escaped or trusted content; decoded output is not safe for direct insertion into HTML.
SequenceGenerator::generate()
- Numeric: digits
0-9 - Alphabetic: uppercase
A-Z - Alphanumeric:
0-9andA-Z
UrlUtils (URI encoding)
- encodeUriComponent(string $value): string — Percent-encode a string for use as any URI component (path segment, query name/value, or fragment). E.g.
a/b→a%2Fb,a b→a%20b. - decodeUriComponent(string $value): string — Decode a percent-encoded URI component (reverse of
encodeUriComponent).
lacus/utils 适用场景与选型建议
lacus/utils 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 635 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「html」 「type」 「random」 「utils」 「utilities」 「sequence」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lacus/utils 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lacus/utils 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lacus/utils 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
A bundle providing fields for image upload with jquery upload and image cropping with jcrop for symfony2
A simple Symfony bundle that adds boolean form field type.
A PHP Abstract Enum Class
This package provides type-safe extension of the laravel collection, forcing a single type of object.
Compatibility layer for emulating enumerations in PHP < 8.1 and native enumerations in PHP >= 8.1
统计信息
- 总下载量: 635
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-11