PHPackages                             cawa0505/laravel-thl-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. cawa0505/laravel-thl-pinyin

ActiveLibrary

cawa0505/laravel-thl-pinyin
===========================

Romanization tool for Traditional Chinese. A Laravel Wrapper for thl/pinyin

161PHP

Since Oct 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/cawa0505/laravel-thl-pinyin)[ Packagist](https://packagist.org/packages/cawa0505/laravel-thl-pinyin)[ RSS](/packages/cawa0505-laravel-thl-pinyin/feed)WikiDiscussions laravel6 Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel-thl-pinyin
==================

[](#laravel-thl-pinyin)

Romanization tool for Traditional Chinese in Laravel5 / Lumen based on [thl/pinyin](https://github.com/thl-pinyin/php-thl-pinyin).

[![Latest Stable Version](https://camo.githubusercontent.com/199995889891e1e7c4fcff45eb7699fb2c1f06b31335e75b2830631affd36bea/68747470733a2f2f706f7365722e707567782e6f72672f63617761303530352f6c61726176656c2d74686c2d70696e79696e2f762f737461626c652e737667)](https://packagist.org/packages/cawa0505/laravel-thl-pinyin) [![Total Downloads](https://camo.githubusercontent.com/40db12b85d016d5ad7c03ee8944d293c676950b1fdfe9dff2cda6abd92c18b00/68747470733a2f2f706f7365722e707567782e6f72672f63617761303530352f6c61726176656c2d74686c2d70696e79696e2f646f776e6c6f6164732e737667)](https://packagist.org/packages/overtrue/laravel-pinyin) [![Latest Unstable Version](https://camo.githubusercontent.com/6bc2266edbbdd5d4e22da28dce83c1368b2a206e7162efddf7ec60b216ceaadc/68747470733a2f2f706f7365722e707567782e6f72672f63617761303530352f6c61726176656c2d74686c2d70696e79696e2f762f756e737461626c652e737667)](https://packagist.org/packages/overtrue/laravel-pinyin) [![License](https://camo.githubusercontent.com/4f41ce08294652e3c577c0137d406b44c8d1b1e4e148ba811e540414c051c926/68747470733a2f2f706f7365722e707567782e6f72672f63617761303530352f6c61726176656c2d74686c2d70696e79696e2f6c6963656e73652e737667)](https://packagist.org/packages/overtrue/laravel-pinyin)

Install
-------

[](#install)

```
composer require "cawa0505/laravel-thl-pinyin"
```

For Laravel if don't discover
-----------------------------

[](#for-laravel-if-dont-discover)

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

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

as optional, you can use facade:

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

For Lumen
---------

[](#for-lumen)

Add the following line to `bootstrap/app.php` after `// $app->withEloquent();`

```
...
// $app->withEloquent();

$app->register(THL\LaravelPinyin\ServiceProvider::class);
...
```

Usage
-----

[](#usage)

#### instance

[](#instance)

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

```
$pinyin = app('thl-pinyin');
echo $pinyin->bpmf('THL台灣華語羅馬拼音');
// returns "THL ㄊㄞˊ ㄨㄢ ㄏㄨㄚˊ ㄩˇ ㄌㄨㄛˊ ㄇㄚˇ ㄆㄧㄣ ㄧㄣ"
```

#### Str Macro

[](#str-macro)

There are some macro to Str

macromethod`Str::pinyin()``app('pinyin')->pinyin()``Str::pinyinSlug()``app('pinyin')->slug()``Str::bpmf()``app('pinyin')->bpmf()````
use Illuminate\Support\Str;

Str::pinyin('THL台灣華語羅馬拼音');
// returns "THL tai2 wan1 hua2 yu3 luo2 ma3 pin1 yin1"

Str::bpmf('THL台灣華語羅馬拼音');
// returns "THL ㄊㄞˊ ㄨㄢ ㄏㄨㄚˊ ㄩˇ ㄌㄨㄛˊ ㄇㄚˇ ㄆㄧㄣ ㄧㄣ"
...
```

#### helper functions

[](#helper-functions)

There are some convenient functions:

functionmethod`pinyin()``app('pinyin')->pinyin()``pinyin_slug()``app('pinyin')->slug()``bpmf()``app('pinyin')->bpmf()````
pinyin('THL台灣華語羅馬拼音');
// returns "THL tai2 wan1 hua2 yu3 luo2 ma3 pin1 yin1"

bpmf('THL台灣華語羅馬拼音');
// returns "THL ㄊㄞˊ ㄨㄢ ㄏㄨㄚˊ ㄩˇ ㄌㄨㄛˊ ㄇㄚˇ ㄆㄧㄣ ㄧㄣ"
...
```

#### Using facade

[](#using-facade)

```
use THL\LaravelPinyin\Facades\Pinyin;

Pinyin::pinyin('THL台灣華語羅馬拼音');
// returns "THL tai2 wan1 hua2 yu3 luo2 ma3 pin1 yin1"

Pinyin::slug('THL台灣華語羅馬拼音');
// returns "thl-tai-wan-hua-yu-luo-ma-pin-yin"
```

About `thl/pinyin` specific configuration and use, refer to: [thl/pinyin](https://github.com/thl-pinyin/php-thl-pinyin)

License
-------

[](#license)

MIT

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/467312520039c167c8b8932f58dabe479a0d4c5a6ff99ddfe95eee550c011b1f?d=identicon)[cawa0505](/maintainers/cawa0505)

---

Top Contributors

[![cawa0505](https://avatars.githubusercontent.com/u/3434037?v=4)](https://github.com/cawa0505 "cawa0505 (25 commits)")

### Embed Badge

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

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

PHPackages © 2026

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