NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #2370 most downloaded on Packagist
Chinese to pinyin translator.
Latest stable
6.0.1
Last release 8 months ago
06 Mar 2026
Ships fairly regularly
a new release about every 5 months
Some releases are documented
notes for 26 of 56 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
56 releases · first in 2014
Drag across the ruler to compare, or tap a release to open it.
Full Changelog: https://github.com/overtrue/pinyin/compare/6.0.0...6.0.1
Full Changelog: https://github.com/overtrue/pinyin/compare/6.0.0...6.0.1
性能优化策略系统: 全新的转换策略架构,针对不同使用场景提供最优性能
Pinyin::useMemoryOptimized() - 切换到内存优化策略Pinyin::useCached() - 切换到缓存策略Pinyin::useSmart() - 切换到智能策略Pinyin::useAutoStrategy() - 自动选择最佳策略Pinyin::clearCache() - 清理所有转换器缓存ConverterFactory::make($strategy) - 创建指定策略的转换器ConverterFactory::recommend() - 获取推荐策略ConverterFactory::getStrategiesInfo() - 获取所有策略信息php benchmark/run.php - 运行性能基准测试php benchmark/compare-strategies.php - 策略对比测试docs/benchmark-guide.md# 运行标准基准测试,显示所有方法的性能表现
php benchmark/run.php
# 详细的策略对比测试,对比三种策略的性能差异
php benchmark/compare-strategies.php
基准测试会显示:
heteronym() 方法(5.3.3+ 引入)继续保持兼容sentence, phrase, chars 等) 保持不变https://github.com/overtrue/pinyin/blob/master/CHANGELOG.md
Full Changelog: https://github.com/overtrue/pinyin/compare/5.3.4...6.0.0
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Pinyin::useMemoryOptimized() - 切换到内存优化策略Pinyin::useCached() - 切换到缓存策略Pinyin::useSmart() - 切换到智能策略Pinyin::useAutoStrategy() - 自动选择最佳策略Pinyin::clearCache() - 清理所有转换器缓存ConverterFactory::make($strategy) - 创建指定策略的转换器ConverterFactory::recommend() - 获取推荐策略ConverterFactory::getStrategiesInfo() - 获取所有策略信息php benchmark/run.php - 运行性能基准测试php benchmark/compare-strategies.php - 策略对比测试docs/benchmark-guide.md# 运行标准基准测试,显示所有方法的性能表现
php benchmark/run.php
# 详细的策略对比测试,对比三种策略的性能差异
php benchmark/compare-strategies.php
基准测试会显示:
heteronym() 方法(5.3.3+ 引入)继续保持兼容sentence, phrase, chars 等) 保持不变从 5.x 升级到 6.0 非常简单,所有现有代码都能正常工作:
// 5.x 和 6.x 都能正常工作
Pinyin::sentence('你好世界');
// 6.x 默认使用内存优化策略,内存占用更低
// 如果你需要与 5.x 完全相同的高性能(高内存占用)
Pinyin::useCached(); // 一次设置,全局生效
Pinyin::sentence('你好世界');
// 自动选择最佳策略(推荐用于新项目)
Pinyin::useAutoStrategy();
// 或者根据场景手动选择:
// Web 应用(内存受限)
Pinyin::useMemoryOptimized();
// 批处理任务(性能优先)
Pinyin::useCached();
// 通用场景(平衡)
Pinyin::useSmart();
// 监控内存使用
$initialMemory = memory_get_usage();
$result = Pinyin::sentence('测试文本');
$memoryUsed = memory_get_usage() - $initialMemory;
echo "内存使用: " . round($memoryUsed / 1024, 2) . " KB";
// 批处理完成后清理缓存
Pinyin::useCached();
// ... 批量处理 ...
Pinyin::clearCache(); // 释放内存
| 策略 | 内存占用 | 首次转换 | 重复转换 | 推荐场景 |
|---|---|---|---|---|
| Memory Optimized | ~400KB | 中等 | 中等 | Web 请求、内存受限环境 |
| Cached | ~4MB | 慢 | 最快 (2-3x) | 批处理、长时运行进程 |
| Smart | 600KB-1.5MB | 快 | 快 | 通用场景、自动优化 |
基于 1000 次转换的基准测试结果:
| 文本长度 | Memory Optimized | Cached | Smart |
|---|---|---|---|
| 短文本 (<10字) | 1.2ms | 0.5ms | 0.8ms |
| 中等文本 (10-50字) | 3.5ms | 1.2ms | 2.1ms |
| 长文本 (>100字) | 8.7ms | 3.1ms | 5.2ms |
修改炔的读音gui为que by @ljyljy0211 in https://github.com/overtrue/pinyin/pull/209
Full Changelog: https://github.com/overtrue/pinyin/compare/5.3.3...5.3.4
Update brainmaestro/composer-git-hooks requirement from ^2.7 to ^3.0 by @dependabot in https://github.com/overtrue/pinyin/pull/204
Full Changelog: https://github.com/overtrue/pinyin/compare/5.3.2...5.3.3
Pinyin::abbr 新增第三个参数 bool $preserveEnglishWords = false, 以保留输入内容的英文单词 #199
Pinyin::abbr 新增第三个参数 bool $preserveEnglishWords = false, 以保留输入内容的英文单词 #199
Full Changelog: https://github.com/overtrue/pinyin/compare/5.3.1...5.3.2
Fixed 「仆区」应该读 pú ōu 而非 pú qū #200
Fixed 「仆区」应该读 pú ōu 而非 pú qū #200
Full Changelog: https://github.com/overtrue/pinyin/compare/5.3.0...5.3.1
feat: 添加sentenceFull,支持保留其他字符 by @libook in https://github.com/overtrue/pinyin/pull/198
Full Changelog: https://github.com/overtrue/pinyin/compare/5.2.2...5.3.0
Full Changelog: https://github.com/overtrue/pinyin/compare/5.2.1...5.2.2
Full Changelog: https://github.com/overtrue/pinyin/compare/5.2.1...5.2.2
Fixed #196 Full Changelog: https://github.com/overtrue/pinyin/compare/5.2.0...5.2.1
Fixed #196
Full Changelog: https://github.com/overtrue/pinyin/compare/5.2.0...5.2.1
新增 Pinyin::polyphonesAsArray 方法,支持多音字逐字返回,#195
Pinyin::polyphonesAsArray 方法,支持多音字逐字返回,#195Full Changelog: https://github.com/overtrue/pinyin/compare/5.1.1...5.2.0
What's Changed * 支持轻声替换,修复 #119 #138 问题 Full Changelog: https://github.com/overtrue/pinyin/compare/5.1.0...5.1.1
What's Changed
Full Changelog: https://github.com/overtrue/pinyin/compare/5.1.0...5.1.1
新增 Pinyin::passportName(string $name, string $toneStyle = Converter::TONE_STYLE_NONE) 方法,使用 yu 代替 ü 输出。
Pinyin::passportName(string $name, string $toneStyle = Converter::TONE_STYLE_NONE) 方法,使用 yu 代替 ü 输出。Full Changelog: https://github.com/overtrue/pinyin/compare/5.0.0...5.1.0
> Completely refactored version, recommended to read the documentation before use.
BREAKING CHANGES
Warning Completely refactored version, recommended to read the documentation before use.
What's changed * 支持轻声替换,解决 #119 #138 问题。 Full Changelog: https://github.com/overtrue/pinyin/compare/4.0.8...4.1.0
What's changed
Full Changelog: https://github.com/overtrue/pinyin/compare/4.0.8...4.1.0
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
- PHP 5.3 support. - Keep numbers in permalink. #54
Support name convert. $pinyin->name('xxx'); #48
$pinyin->name('xxx'); #48- 重新设计的结构 - 内存占用更少 - 提供生成工具,便于大家补充词典 - 新的 API,更贴近使用场景
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
【优化】删除附加词文件,改为只从src/data/dict.php 读取,此后补充也从此文件补充
src/data/dict.php 读取,此后补充也从此文件补充Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
-【更新】Pinyin::pinyin() 更名为 Pinyin::trans() -【删除】不再支持繁体 -【删除】删除配置项 letter
-【更新】Pinyin::pinyin() 更名为 Pinyin::trans()
-【删除】不再支持繁体
-【删除】删除配置项 letter
Nothing published for this version
【新增】Pinyin::appends($appends= array()) 载入用户自定义词典
- 【bugfix】首字母方法在部分单音节时丢字母 - 【添加】补充错误字“腊(la4)”
Nothing published for this version
【bugfix】Laravel service provider 未读取到配置Bug修复。
Nothing published for this version
【更新】letter()第二参数更新为数组array('delimiter' => '', 'uppercase' => false);
【更新】代码添加scrutinizer-ci的代码质量分析服务,调整部分代码
- 【添加】添加CI自动化测试 - 【更新】添加拼音大小写统一处理 - 【更新】修改代码写法,支持旧版php - 【更新】更新Readme说明文档 - 【bugfix】修复代码书写错误
Nothing published for this version
Pinyin::trans('带着希望去旅行,比到达终点更美好');
Pinyin::trans('带着希望去旅行,比到达终点更美好');
Nothing published for this version
Nothing published for this version
One column per quarter.