PHPackages                             overtrue/laravel-pinyin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. overtrue/laravel-pinyin

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

overtrue/laravel-pinyin
=======================

Chinese to Pinyin translator.

6.1.0(2mo ago)531600.6k↑401%60[1 PRs](https://github.com/overtrue/laravel-pinyin/pulls)12MITPHPPHP &gt;=8.1

Since Mar 15Pushed 1mo ago10 watchersCompare

[ Source](https://github.com/overtrue/laravel-pinyin)[ Packagist](https://packagist.org/packages/overtrue/laravel-pinyin)[ GitHub Sponsors](https://github.com/overtrue)[ RSS](/packages/overtrue-laravel-pinyin/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (8)Versions (20)Used By (12)

Laravel-Pinyin
==============

[](#laravel-pinyin)

Chinese to Pinyin translator for Laravel based on [overtrue/pinyin](https://github.com/overtrue/pinyin).

[![Latest Stable Version](https://camo.githubusercontent.com/e391e5f29e08f70cc620dbd5e9a220acb6e5072e1b443bae2c8466715a883ec1/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f6c61726176656c2d70696e79696e2f762f737461626c652e737667)](https://packagist.org/packages/overtrue/laravel-pinyin) [![Total Downloads](https://camo.githubusercontent.com/919ddfd26e84be24371cc63cf9309e9dc9fe7a554a44bd6559cd2e01dca7b786/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f6c61726176656c2d70696e79696e2f646f776e6c6f6164732e737667)](https://packagist.org/packages/overtrue/laravel-pinyin) [![Latest Unstable Version](https://camo.githubusercontent.com/8d759862b4466a76c77dd1dd32a5d33275c71eecbda751021d3c3d1f870d288b/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f6c61726176656c2d70696e79696e2f762f756e737461626c652e737667)](https://packagist.org/packages/overtrue/laravel-pinyin) [![License](https://camo.githubusercontent.com/4a6826aa32ef7937465c502cf9b86f1951c0fb8f714639a477567ae87c8058ae/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f6c61726176656c2d70696e79696e2f6c6963656e73652e737667)](https://packagist.org/packages/overtrue/laravel-pinyin)

[![Sponsor me](https://github.com/overtrue/overtrue/raw/master/sponsor-me-button-s.svg?raw=true)](https://github.com/sponsors/overtrue)

Install
-------

[](#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
-----

[](#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:

functionmethod`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](https://github.com/overtrue/pinyin)

Performance Strategies (New in 6.0)
-----------------------------------

[](#performance-strategies-new-in-60)

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
-------------

[](#heart-sponsor-me)

[![Sponsor me](https://github.com/overtrue/overtrue/raw/master/sponsor-me.svg?raw=true)](https://github.com/sponsors/overtrue)

如果你喜欢我的项目并想支持它，[点击这里 ❤️](https://github.com/sponsors/overtrue)

Project supported by JetBrains
------------------------------

[](#project-supported-by-jetbrains)

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

[![](https://camo.githubusercontent.com/3cf726e7cdadba47755b7f7ea4227945a92a2fa48aadf4a2573140ec6501c989/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f73746f726167652f70726f64756374732f636f6d70616e792f6272616e642f6c6f676f732f6a625f6265616d2e737667)](https://www.jetbrains.com/?from=https://github.com/overtrue)

PHP 扩展包开发
---------

[](#php-扩展包开发)

> 想知道如何从零开始构建 PHP 扩展包？
>
> 请关注我的实战课程，我会在此课程中分享一些扩展开发经验 —— [《PHP 扩展包实战教程 - 从入门到发布》](https://learnku.com/courses/creating-package)

License
-------

[](#license)

MIT

###  Health Score

69

—

FairBetter than 100% of packages

Maintenance88

Actively maintained with recent releases

Popularity58

Moderate usage in the ecosystem

Community33

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~269 days

Recently: every ~189 days

Total

16

Last Release

79d ago

Major Versions

1.2.1 → 3.0.02016-04-22

3.0.5 → 4.0.02018-10-10

4.0.0 → 5.0.02023-02-15

5.2.0 → 6.0.02025-09-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/c507e57eab402e81335012357b7d7df6c5cafda3073adcc94b475037127d263f?d=identicon)[overtrue](/maintainers/overtrue)

---

Top Contributors

[![overtrue](https://avatars.githubusercontent.com/u/1472352?v=4)](https://github.com/overtrue "overtrue (45 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (2 commits)")[![hihuangwei](https://avatars.githubusercontent.com/u/3166799?v=4)](https://github.com/hihuangwei "hihuangwei (2 commits)")[![eduardocruz](https://avatars.githubusercontent.com/u/161669?v=4)](https://github.com/eduardocruz "eduardocruz (1 commits)")[![summerblue](https://avatars.githubusercontent.com/u/324764?v=4)](https://github.com/summerblue "summerblue (1 commits)")[![jerray](https://avatars.githubusercontent.com/u/591094?v=4)](https://github.com/jerray "jerray (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")

---

Tags

chinesechinese-to-pinyinlaravelpinyinlaravelPinyinChineseovertrue

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/overtrue-laravel-pinyin/health.svg)

```
[![Health](https://phpackages.com/badges/overtrue-laravel-pinyin/health.svg)](https://phpackages.com/packages/overtrue-laravel-pinyin)
```

###  Alternatives

[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17818.7k](/packages/markwalet-nova-modal-response)[firefly-iii/data-importer

Firefly III Data Import Tool.

7965.8k](/packages/firefly-iii-data-importer)[nickurt/laravel-akismet

Akismet for Laravel 11.x/12.x/13.x

98145.2k3](/packages/nickurt-laravel-akismet)[creasi/laravel-nusa

A Laravel package that aim to provide Indonesia' Administrative Data

997.7k2](/packages/creasi-laravel-nusa)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1319.7k3](/packages/team-nifty-gmbh-tall-datatables)[lokielse/laravel-pinyin

Chinese Pinyin Bundle For Laravel

1413.8k](/packages/lokielse-laravel-pinyin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
