revolution/laravel-str-mixins
Composer 安装命令:
composer require revolution/laravel-str-mixins
包简介
Laravel Str mixins
README 文档
README
Mixin that extends Illuminate\Support\Str mainly for Japanese language use
Requirements
- PHP >= 8.3
- Laravel >= 12.0
Versioning
| ver | PHP | Laravel |
|---|---|---|
| 1.x | ^7.2 | 6 |
| 2.x | ^8.3 | ^12 |
- v1.x is for Laravel 6 only.
- v2.x supports Laravel 7 and above only for Fluent Strings.
Installation
composer require revolution/laravel-str-mixins
Uninstall
composer remove revolution/laravel-str-mixins
Str
Str::textwrap(string $str, int $width = 10, string $break = PHP_EOL): string
Line breaks at specified number of characters. Simple line breaks without word-wrapping rules.
$text = Str::textwrap(str: 'abcde', width: 3); // abc // de
Originally intended for forcing line breaks to fit within OGP image width.
Changed to textwrap because Laravel 10.19.0 added a function with the same name Str::wordWrap(). Kept instead of removing because the behavior is different. Str::wordWrap() doesn't work as expected with Japanese text.
Str::kana(string $str, string $option = 'KV', string $encoding = 'UTF-8'): string
Same as mb_convert_kana().
$text = Str::kana(str: 'abcあいうアイウ', option: 'KVa'); // abcあいうアイウ
Str::truncate(string $str, int $limit = 100, string $end = '...'): string
Str::limit() counts half-width characters as 1 and full-width characters as 2 when truncating. It uses multibyte functions but counts by character width.
$text = Str::limit('abcあいうえお', 7); // abcあい...
Str::truncate() counts by the number of characters for truncation, which works better for Japanese text.
$text = Str::truncate(str: 'abcあいうえお', limit: 7); // abcあいうえ...
Fluent Strings
textwrap(int $width = 10, string $break = PHP_EOL): Stringable
$text = Str::of('abcde')->textwrap(width: 3)->value(); // abc // de
kana(string $option = 'KV', string $encoding = 'UTF-8'): Stringable
$text = Str::of('abcあいうアイウ')->kana(option: 'KVa')->value(); // abcあいうアイウ
For chaining use:
$text = Str::of('abcあいうアイウ')->kana(option: 'KVa')->textwrap(3)->value(); // abc // あいう // アイウ
truncate(int $limit = 100, string $end = '...'): Stringable
$text = Str::of('abcあいうえお')->truncate(limit: 6, end: '___')->value(); // abcあいう___
LICENSE
MIT
revolution/laravel-str-mixins 适用场景与选型建议
revolution/laravel-str-mixins 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25.64k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 10 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「mixins」 「str」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 revolution/laravel-str-mixins 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 revolution/laravel-str-mixins 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 revolution/laravel-str-mixins 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Utility classes meant to facilitate object manipulation.
Generate phpDoc for laravel macroable class.
Simple curly braces micro templating
LESS mixins forked from Bootstrap
Alfabank REST API integration
Data structure that allows the definition of arbitrary methods and properties at runtime
统计信息
- 总下载量: 25.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-01