overtrue/laravel-pinyin 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

overtrue/laravel-pinyin

Composer 安装命令:

composer require overtrue/laravel-pinyin

包简介

Chinese to Pinyin translator.

README 文档

README

Chinese to Pinyin translator for Laravel based on overtrue/pinyin.

Latest Stable Version Total Downloads Latest Unstable Version License

Sponsor me

Install

composer require "overtrue/laravel-pinyin:^6.0"

The auto-discovery feature will handle these two steps for you.

Add the following line to the section providers of config/app.php:

'providers' => [
    //...
    Overtrue\LaravelPinyin\ServiceProvider::class,
],

as optional, you can use facade:

'aliases' => [
    //...
    'Pinyin' => Overtrue\LaravelPinyin\Facades\Pinyin::class,
],

Usage

you can get the instance of Overtrue\Pinyin\Pinyin from app container:

$pinyin = app('pinyin');
echo $pinyin->sentence('带着希望去旅行,比到达终点更美好');
// dài zhe xī wàng qù lǔ xíng, bǐ dào dá zhōng diǎn gèng měi hǎo

There are more convenient functions:

function method
pinyin() app('pinyin')->convert()
pinyin_abbr() app('pinyin')->abbr()
pinyin_permalink app('pinyin')->permalink()
pinyin_sentence app('pinyin')->sentence()
var_dump(pinyin('带着希望去旅行,比到达终点更美好'));
// ["dai", "zhe", "xi", "wang", "qu", "lv", "xing", "bi", "dao", "da", "zhong", "dian", "geng", "mei", "hao"]

var_dump(pinyin_abbr('带着希望去旅行'));
// dzxwqlx
...

Using facade:

use Pinyin; // Facade class, NOT Overtrue\Pinyin\Pinyin

var_dump(Pinyin::convert('带着希望去旅行'));
// ["dai", "zhe", "xi", "wang", "qu", "lv", "xing"]

echo Pinyin::sentence('带着希望去旅行,比到达终点更美好');
// dài zhe xī wàng qù lǔ xíng, bǐ dào dá zhōng diǎn gèng měi hǎo

About overtrue/pinyin specific configuration and use, refer to: overtrue/pinyin

Performance Strategies (New in 6.0)

Laravel-pinyin 6.0 includes support for the new performance optimization strategies introduced in overtrue/pinyin 6.0:

use Overtrue\Pinyin\Pinyin;

// Memory Optimized (default) - ~400KB memory usage, suitable for web requests
Pinyin::useMemoryOptimized();

// Cached Strategy - ~4MB memory usage, 2-3x faster for repeated conversions
Pinyin::useCached();

// Smart Strategy - 600KB-1.5MB memory usage, adaptive loading
Pinyin::useSmart();

// Auto Strategy - automatically selects the best strategy for your environment
Pinyin::useAutoStrategy();

// Clear cache when needed (useful in long-running processes)
Pinyin::clearCache();

❤️ Sponsor me

Sponsor me

如果你喜欢我的项目并想支持它,点击这里 ❤️

Project supported by JetBrains

Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?

请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》

License

MIT

overtrue/laravel-pinyin 适用场景与选型建议

overtrue/laravel-pinyin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 607.07k 次下载、GitHub Stars 达 531, 最近一次更新时间为 2015 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「Chinese」 「Pinyin」 「overtrue」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 overtrue/laravel-pinyin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 overtrue/laravel-pinyin 我们能提供哪些服务?
定制开发 / 二次开发

基于 overtrue/laravel-pinyin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 607.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 542
  • 点击次数: 37
  • 依赖项目数: 15
  • 推荐数: 0

GitHub 信息

  • Stars: 531
  • Watchers: 10
  • Forks: 60
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-15