PackageTrack
Sign in Get early access

overtrue/pinyin

Chinese to pinyin translator.

6.0.1 7.2M downloads/mo #2054 most downloaded on Packagist overtrue/pinyin

What this package is like to depend on

Last release 5 months ago

06 Mar 2026

Ships fairly regularly

a new release about every 5 months

Rarely documented

notes for 12 of 56 stable releases

Nothing withdrawn

no release was ever pulled

12 years old

56 releases · first in 2014

2 releases in the last 12 months

see the full history below

Release timeline

56 releases · Jul 2014 to Mar 2026
2015 2017 2019 2021 2023 2025
Release Pre-release

Releases

latest 56
  1. 6.0.1 06 Mar 2026
    Release notes

    Full Changelog: 6.0.0...6.0.1

    Open source →
  2. 6.0.0 08 Sep 2025
    Release notes

    🚀 Major Features

    • 性能优化策略系统: 全新的转换策略架构,针对不同使用场景提供最优性能
      • 内存优化策略 (Memory Optimized): 占用 ~400KB 内存,适合 Web 请求和内存受限环境
      • 缓存策略 (Cached): 占用 ~4MB 内存,重复转换性能提升 2-3 倍,适合批处理任务
      • 智能策略 (Smart): 占用 600KB-1.5MB 内存,根据文本复杂度自适应加载
    • ConverterFactory: 新的工厂模式管理转换器实例和策略选择
    • 自动策略选择: 根据运行环境(Web/CLI/内存限制)自动推荐最佳策略
    • 性能基准测试工具: 内置的策略性能对比和监控工具
    • 内存监控: 支持实时监控内存使用情况和性能指标

    🔧 API Changes

    • 新增 Pinyin::useMemoryOptimized() - 切换到内存优化策略
    • 新增 Pinyin::useCached() - 切换到缓存策略
    • 新增 Pinyin::useSmart() - 切换到智能策略
    • 新增 Pinyin::useAutoStrategy() - 自动选择最佳策略
    • 新增 Pinyin::clearCache() - 清理所有转换器缓存
    • 新增 ConverterFactory::make($strategy) - 创建指定策略的转换器
    • 新增 ConverterFactory::recommend() - 获取推荐策略
    • 新增 ConverterFactory::getStrategiesInfo() - 获取所有策略信息

    ⚡ Performance Improvements

    • 内存使用优化: 默认内存占用从 ~4MB 降低到 ~400KB
    • 转换速度提升: 缓存策略下重复转换速度提升 2-3 倍
    • 智能加载: 根据文本复杂度动态调整数据加载策略
    • 按需加载: 内存优化策略仅在需要时加载转换数据

    📊 Benchmark & Monitoring

    • 新增 php benchmark/run.php - 运行性能基准测试
    • 新增 php benchmark/compare-strategies.php - 策略对比测试
    • 新增基准测试文档 docs/benchmark-guide.md
    • 支持内存使用情况实时监控

    运行基准测试

    # 运行标准基准测试,显示所有方法的性能表现
    php benchmark/run.php
    
    # 详细的策略对比测试,对比三种策略的性能差异
    php benchmark/compare-strategies.php

    基准测试会显示:

    • 每种策略的执行时间和内存使用情况
    • 不同文本长度下的性能表现
    • 策略之间的性能对比和推荐场景

    🔄 Breaking Changes

    • 默认策略变更: 从全缓存改为内存优化策略,降低默认内存占用
    • 转换器架构重构: 引入策略模式,旧的直接实例化转换器方式仍兼容
    • 性能特征变化: 首次转换可能略慢,但内存占用显著降低

    🔧 Backward Compatibility

    • 完全兼容 5.x API,现有代码无需修改即可使用
    • heteronym() 方法(5.3.3+ 引入)继续保持兼容
    • 所有原有的转换方法 (sentence, phrase, chars 等) 保持不变

    📚 Documentation

    • 更新 README.md 增加性能优化策略说明
    • 新增性能对比表格和使用建议
    • 新增基准测试指南
    • 新增性能优化最佳实践

    🔧 Development Tools

    • 新增性能基准测试脚本
    • 新增策略对比工具
    • 增强命令行工具支持策略选择

    https://github.com/overtrue/pinyin/blob/master/CHANGELOG.md

    New Contributors

    • @Copilot made their first contribution in #216

    Full Changelog: 5.3.4...6.0.0

    Open source →
    Release notes

    🚀 Major Features

    • 性能优化策略系统: 全新的转换策略架构,针对不同使用场景提供最优性能
      • 内存优化策略 (Memory Optimized): 占用 ~400KB 内存,适合 Web 请求和内存受限环境
      • 缓存策略 (Cached): 占用 ~4MB 内存,重复转换性能提升 2-3 倍,适合批处理任务
      • 智能策略 (Smart): 占用 600KB-1.5MB 内存,根据文本复杂度自适应加载
    • ConverterFactory: 新的工厂模式管理转换器实例和策略选择
    • 自动策略选择: 根据运行环境(Web/CLI/内存限制)自动推荐最佳策略
    • 性能基准测试工具: 内置的策略性能对比和监控工具
    • 内存监控: 支持实时监控内存使用情况和性能指标

    🔧 API Changes

    • 新增 Pinyin::useMemoryOptimized() - 切换到内存优化策略
    • 新增 Pinyin::useCached() - 切换到缓存策略
    • 新增 Pinyin::useSmart() - 切换到智能策略
    • 新增 Pinyin::useAutoStrategy() - 自动选择最佳策略
    • 新增 Pinyin::clearCache() - 清理所有转换器缓存
    • 新增 ConverterFactory::make($strategy) - 创建指定策略的转换器
    • 新增 ConverterFactory::recommend() - 获取推荐策略
    • 新增 ConverterFactory::getStrategiesInfo() - 获取所有策略信息

    ⚡ Performance Improvements

    • 内存使用优化: 默认内存占用从 ~4MB 降低到 ~400KB
    • 转换速度提升: 缓存策略下重复转换速度提升 2-3 倍
    • 智能加载: 根据文本复杂度动态调整数据加载策略
    • 按需加载: 内存优化策略仅在需要时加载转换数据

    📊 Benchmark & Monitoring

    • 新增 php benchmark/run.php - 运行性能基准测试
    • 新增 php benchmark/compare-strategies.php - 策略对比测试
    • 新增基准测试文档 docs/benchmark-guide.md
    • 支持内存使用情况实时监控

    运行基准测试

    # 运行标准基准测试,显示所有方法的性能表现
    php benchmark/run.php
    
    # 详细的策略对比测试,对比三种策略的性能差异
    php benchmark/compare-strategies.php
    

    基准测试会显示:

    • 每种策略的执行时间和内存使用情况
    • 不同文本长度下的性能表现
    • 策略之间的性能对比和推荐场景

    🔄 Breaking Changes

    • 默认策略变更: 从全缓存改为内存优化策略,降低默认内存占用
    • 转换器架构重构: 引入策略模式,旧的直接实例化转换器方式仍兼容
    • 性能特征变化: 首次转换可能略慢,但内存占用显著降低

    🔧 Backward Compatibility

    • 完全兼容 5.x API,现有代码无需修改即可使用
    • heteronym() 方法(5.3.3+ 引入)继续保持兼容
    • 所有原有的转换方法 (sentence, phrase, chars 等) 保持不变

    📚 Documentation

    • 更新 README.md 增加性能优化策略说明
    • 新增性能对比表格和使用建议
    • 新增基准测试指南
    • 新增性能优化最佳实践

    🔧 Development Tools

    • 新增性能基准测试脚本
    • 新增策略对比工具
    • 增强命令行工具支持策略选择

    🛠️ Migration Guide

    从 5.x 升级到 6.0 非常简单,所有现有代码都能正常工作:

    无需任何修改(推荐)

    // 5.x 和 6.x 都能正常工作
    Pinyin::sentence('你好世界');
    // 6.x 默认使用内存优化策略,内存占用更低
    

    保持 5.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();  // 释放内存
    

    💡 Performance Comparison

    策略 内存占用 首次转换 重复转换 推荐场景
    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
    Open source →
  3. 5.3.4 16 Mar 2025
    Release notes

    What's Changed

    New Contributors

    Full Changelog: 5.3.3...5.3.4

    Open source →
    Release notes

    🚀 Features

    • Resolved #211

    ⚙️ Miscellaneous Tasks

    • Format
    Open source →
  4. 5.3.3 01 Aug 2024
    Release notes

    What's Changed

    • Fixed #207
    • Update brainmaestro/composer-git-hooks requirement from ^2.7 to ^3.0 by @dependabot in #204
    • Update nunomaduro/termwind requirement from ^1.13 to ^2.0 by @dependabot in #206
    • Update phpunit/phpunit requirement from ^10.1 to ^11.2 by @dependabot in #205

    Full Changelog: 5.3.2...5.3.3

    Open source →
    Release notes

    🚀 Features

    • 使用 heteronym 代替 polyphonic 多音字 #184
    • 取首字母时,能否保留完整的英文 #199

    🐛 Bug Fixes

    • 修复 琢 的音频顺序 #207
    • 补充案例 #207
    • Tests
    • Tests
    Open source →
  5. 5.3.2 19 Mar 2024
    Release notes

    Pinyin::abbr 新增第三个参数 bool $preserveEnglishWords = false, 以保留输入内容的英文单词 #199

    Full Changelog: 5.3.1...5.3.2

    Open source →
    Release notes

    🚀 Features

    • 取首字母时,能否保留完整的英文 #199
    Open source →
  6. 5.3.1 19 Mar 2024
    Release notes

    Fixed 「仆区」应该读 pú ōu 而非 pú qū #200

    Full Changelog: 5.3.0...5.3.1

    Open source →
    Release notes

    🐛 Bug Fixes

    • 「仆区」应该读 pú ōu 而非 pú qū #200
    • Tests #200
    Open source →
  7. 5.3.0 27 Oct 2023
    Release notes

    What's Changed

    • feat: 添加sentenceFull,支持保留其他字符 by @libook in #198

    New Contributors

    Full Changelog: 5.2.2...5.3.0

    Open source →
    Release notes

    🚀 Features

    • 添加sentenceFull,支持保留其他字符 (#198)
    • Full sentence, #198
    Open source →
  8. 5.2.2 27 Sep 2023
    Release notes

    Full Changelog: 5.2.1...5.2.2

    Open source →
    Release notes

    ⚙️ Miscellaneous Tasks

    • Bin
    Open source →
  9. 5.2.1 17 Jun 2023
    Release notes

    Fixed #196

    Full Changelog: 5.2.0...5.2.1

    Open source →
    Release notes

    🐛 Bug Fixes

    • Bin
    Open source →
  10. 5.2.0 12 Jun 2023
    Release notes

    What's Changed

    • 新增 Pinyin::polyphonesAsArray 方法,支持多音字逐字返回,#195
    • Update phpunit/phpunit requirement from ^9.5 to ^10.1 by @dependabot in #192

    Full Changelog: 5.1.1...5.2.0

    Open source →
    Release notes

    🚀 Features

    • 增加 Pinyin::polyphonesAsArray. fixed #195

    📚 Documentation

    • 更新文档提示
    • 更新文档提示
    • 更新文档提示
    Open source →
  11. 5.1.1 27 Apr 2023

    Nothing published for this version

  12. 5.1.0 27 Apr 2023
    Release notes

    💼 Other

    • 移除错误语法 (#190)
    Open source →
  13. 5.0.0 24 Jul 2022
    Release notes

    🐛 Bug Fixes

    • 优化符号匹配规则
    Open source →
  14. 4.1.0 27 Apr 2023

    Nothing published for this version

  15. 4.0.8 19 Jul 2021

    Nothing published for this version

  16. 4.0.7 16 Apr 2021

    Nothing published for this version

  17. 4.0.6 13 Apr 2020

    Nothing published for this version

  18. 4.0.5 20 Sep 2019

    Nothing published for this version

  19. 4.0.4 17 Sep 2019

    Nothing published for this version

  20. 4.0.3 21 Apr 2019

    Nothing published for this version

  21. 4.0.2 21 Apr 2019

    Nothing published for this version

  22. 4.0.1 11 Jan 2019

    Nothing published for this version

  23. 4.0.0 20 Sep 2018

    Nothing published for this version

  24. 3.0.6 10 Jul 2017

    Nothing published for this version

  25. 3.0.5 27 Feb 2017

    Nothing published for this version

  26. 3.0.4 17 Aug 2016

    Nothing published for this version

  27. 3.0.3 13 Jun 2016

    Nothing published for this version

  28. 3.0.2 22 May 2016

    Nothing published for this version

  29. 3.0.1 18 May 2016

    Nothing published for this version

  30. 3.0.0 25 Apr 2016

    Nothing published for this version

  31. 2.6.8 05 Apr 2016

    Nothing published for this version

  32. 2.6.7 19 Jan 2016

    Nothing published for this version

  33. 2.6.5 18 Jan 2016

    Nothing published for this version

  34. 2.6.4 22 Dec 2015

    Nothing published for this version

  35. 2.6.3 28 Oct 2015

    Nothing published for this version

  36. 2.6.2 21 Oct 2015

    Nothing published for this version

  37. 2.6.1 04 Sep 2015

    Nothing published for this version

  38. 2.6.0 01 Aug 2015

    Nothing published for this version

  39. 2.5.4 25 Jul 2015

    Nothing published for this version

  40. 2.5.3 02 Jul 2015

    Nothing published for this version

  41. 2.5.2 01 Jun 2015

    Nothing published for this version

  42. 2.5.1 28 Apr 2015

    Nothing published for this version

  43. 2.5.0 16 Mar 2015

    Nothing published for this version

  44. 2.4.1 14 Jan 2015

    Nothing published for this version

  45. 2.4.0 25 Dec 2014

    Nothing published for this version

  46. 2.3.1 27 Nov 2014

    Nothing published for this version

  47. 2.3.0 26 Nov 2014

    Nothing published for this version

  48. 2.2.1 22 Nov 2014

    Nothing published for this version

  49. v2.0 08 Oct 2014

    Nothing published for this version

  50. 2.2 22 Nov 2014

    Nothing published for this version

  51. 2.1 02 Nov 2014

    Nothing published for this version

  52. 1.4 06 Oct 2014

    Nothing published for this version

  53. 1.3 06 Oct 2014

    Nothing published for this version

  54. 1.1 16 Jul 2014

    Nothing published for this version

  55. 1.0-beta 16 Jul 2014

    Nothing published for this version

  56. 1.0 16 Jul 2014

    Nothing published for this version

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive