simbiat/cute-bytes
Composer 安装命令:
composer require simbiat/cute-bytes
包简介
Class to present bytes in readable format
README 文档
README
Class to present bytes (numeric value) as a human-readable string. There are several reasons you would want to use this library and not the common one-liner (or 3-liner) approach:
- No missing postfixes in case of too big or too small values.
- No superfluous trailing zeros.
- Follows SI format by default (power of 10 can be switched to power of 2, if so desired).
- Shows thousands by default (adjustable) for extra readability in some cases.
How to use
Easy:
echo \Simbiat\CuteBytes::bytes(1234567890);
will output 1,234.57 MB
You can change decimal and thousands delimiters or change the number of decimals (precision)
echo \Simbiat\CuteBytes::bytes(1234567890, decimals: 3, dec_point: ',', thousands_sep: '.');
to get 1.234,568 MB
If you want to drop thousands, set the default number of numbers shown
echo \Simbiat\CuteBytes::bytes(1234567890, numbers: 0);
to get 1.23 GB
If you want to use "classic" logic, that is binary, power of 2, use
echo \Simbiat\CuteBytes::bytes(1234567890, 1024);
to get 1,177.38 MB (note some additional loss of precision)
simbiat/cute-bytes 适用场景与选型建议
simbiat/cute-bytes 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 355 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 12 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「human」 「readable」 「bytes」 「cute」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 simbiat/cute-bytes 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 simbiat/cute-bytes 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 simbiat/cute-bytes 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Convert a value in seconds into a human-readable convenience duration
Additional Twig filters and tests.
PHP implementation of python's struct module.
PHP Accessories: Classes etc.
Extend laravel applications with more artisan commands, traits and useful helper classes
Eloquent file size calculations and formatting for Laravel
统计信息
- 总下载量: 355
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 2
其他信息
- 授权协议: AGPL-3.0-or-later
- 更新时间: 2018-12-17