doughmii/dev-utils
最新稳定版本:v1.0.2
Composer 安装命令:
composer require doughmii/dev-utils
包简介
A collection of small and useful PHP utilities for daily development
README 文档
README
English | 简体中文
A lightweight PHP utility toolkit for daily development. Modular design — currently includes a Base62 encoder and a human-friendly time formatter, and more tools can be added over time.
Installation
Install via Composer:
composer require doughmii/dev-utils
Usage
🔢 Base62Encoder
A simple Base62 encoder/decoder that supports optional salt and batch encoding.
use DoughMii\DevUtils\Id\Base62Encoder; $encoder = new Base62Encoder(); // Encode and decode a single integer $encoded = $encoder->encode(123456); $decoded = $encoder->decode($encoded); // Encode and decode with salt $encodedSalted = $encoder->encode(123456, 'my-salt'); $decodedSalted = $encoder->decode($encodedSalted, 'my-salt'); // Encode and decode multiple integers $data = [1, 2, 3]; $encodedMultiple = $encoder->encodeMultiple($data, 'salt123'); $decodedMultiple = $encoder->decodeMultiple($encodedMultiple, count($data), 'salt123');
🕒 TimeHumanizer
Converts time differences into human-friendly text, supporting multiple languages (English, Chinese) and precise month/year logic.
use DoughMii\DevUtils\Time\TimeHumanizer; $now = new DateTimeImmutable(); $past = $now->modify('-3 days'); echo TimeHumanizer::diffForHumans($past); // e.g. "3 days ago" echo TimeHumanizer::fromNow($past); // same as above // With custom locale (zh) echo TimeHumanizer::diffForHumans($past, null, 'zh'); // "3 天前"
测试
运行 PHPUnit 测试:
vendor/bin/phpunit
许可证
MIT
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-27