overtrue/pinyin
Convert Chinese characters to Pinyin in PHP/Laravel. overtrue/pinyin supports full pinyin, initials, tone options, segmentation, and custom dictionaries—ideal for search indexing, sorting, slugs, and transliteration in web apps.
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
Full Changelog: https://github.com/overtrue/pinyin/compare/5.3.3...5.3.4
Full Changelog: https://github.com/overtrue/pinyin/compare/5.3.2...5.3.3
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
Full Changelog: https://github.com/overtrue/pinyin/compare/5.3.0...5.3.1
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
Fixed #196
Full Changelog: https://github.com/overtrue/pinyin/compare/5.2.0...5.2.1
Pinyin::polyphonesAsArray 方法,支持多音字逐字返回,#195Full Changelog: https://github.com/overtrue/pinyin/compare/5.1.1...5.2.0
What's changed
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/5.1.0...5.1.1
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
BREAKING CHANGES
Warning Completely refactored version, recommended to read the documentation before use.
Bugfix. #95
$pinyin->name('xxx'); #48How can I help you explore Laravel packages today?