syntatis/utils
Composer 安装命令:
composer require syntatis/utils
包简介
Handy functions for PHP
README 文档
README
The syntatis/utils package provides a variety of utility functions to simplify common tasks in PHP, including validation, case conversion, and inflection.
Installation
You can install the package via Composer:
composer require syntatis/utils
Usage
Validator
This package includes several functions for validating values, such as checking if a value is an email, URL, or whether it is blank.
| Function | Description |
|---|---|
Val::isBlank |
Checks if a value is blank or empty. |
Val::isEmail |
Checks if a value is a valid email address. |
Val::isURL |
Checks if a value is a valid URL. |
Val::isUUID |
Checks if a value is a valid UUID. |
Val::isSemVer |
Checks if a value is in valid SemVer format. |
Val::isIPAddress |
Checks if a value is a valid IPv4 or IPv6 address. |
Val::isUnique |
Checks if all elements in a collection are unique. |
Examples
use function Syntatis\Utils\Val; // Check if a value is blank or empty Val::isBlank(''); // true Val::isBlank(' '); // true Val::isBlank('foo '); // false // Check if a value is a valid email address Val::isEmail('example@example.com'); // true Val::isEmail('invalid-email'); // false
Strings
This package includes several functions to handle strings, such as converting a string to camel case, makes a word plural, or checking if a string starts with a specific substring.
| Function | Description |
|---|---|
Str::toCamelCase |
Converts a string to camel case e.g. foo_bar to fooBar. |
Str::toSnakeCase |
Converts a string to snake case e.g. fooBar to foo_bar. |
Str::toKebabCase |
Converts a string to kebab case e.g. fooBar to foo-bar. |
Str::toPascalCase |
Converts a string to Pascal case e.g. foo_bar to FooBar. |
Str::toTitleCase |
Converts a string to title case e.g. foo_bar to Foo Bar. |
Str::toSentenceCase |
Converts a string to sentence case e.g. foo_bar to Foo bar. |
Str::toLowerCase |
Converts a string to lower case e.g. FooBar to foobar. |
Str::toUpperCase |
Converts a string to upper case e.g. fooBar to FOOBAR. |
Str::toMacroCase |
Converts a string to macro case e.g. fooBar to FOO_BAR. |
Str::toCobolCase |
Converts a string to Cobol case e.g. fooBar to FOO-BAR. |
Str::startsWith |
Check if a string starts with a specific substring. |
Str::endsWith |
Check if a string ends with a specific substring. |
Examples
use function Syntatis\Utils\Str; // Convert a string to camel case Str::toCamelCase('foo_bar'); // fooBar // Check if a string starts with a specific substring Str::startsWith('Hello, World!', 'Hello'); // true
Arrays
This package includes several functions to handle arrays. For example, checking if an array is a list or associative array, or checking if all elements in an array are unique.
| Function | Description |
|---|---|
Arr::isList |
Checks if an array is a list. If not then it is an associative array. |
Arr::isUnique |
Checks if all elements in an array are unique. |
syntatis/utils 适用场景与选型建议
syntatis/utils 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 50.23k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2023 年 12 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「validator」 「utilities」 「case-converter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 syntatis/utils 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 syntatis/utils 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 syntatis/utils 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Convert strings from and to AdaCase, CamelCase, CobolCase, KebabCase, Lowercase, MacroCase, PascalCase, SentenceCase, SnakeCase, TitleCase, TrainCase, and Uppercase
Runn Me! Validation and Sanitization Library
Extension for Opis JSON Schema
🔤 Twig extension for Case Converter
A collection of enhancements and utilities for the Silverstripe UserForms module
Laravel credit card validator 2 from rap2hpoutre
统计信息
- 总下载量: 50.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-29