PHPackages                             alismall/zplite - 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. alismall/zplite

ActiveLibrary

alismall/zplite
===============

1.0.0(6y ago)013MITPHP

Since Dec 24Pushed 6y ago1 watchersCompare

[ Source](https://github.com/aliSmallNo/zplite)[ Packagist](https://packagist.org/packages/alismall/zplite)[ RSS](/packages/alismall-zplite/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Pinyin
======

[](#pinyin)

词典的中文转拼音工具，更准确的支持多音字的汉字转拼音解决方案。

安装
--

[](#安装)

使用 Composer 安装:

```
composer require "alismall/zplite"

```

使用
--

[](#使用)

### 拼音数组

[](#拼音数组)

```
$pinyin = new Pinyin(); // 默认

$pinyin->convert('带着希望去旅行，比到达终点更美好');
// ["dai", "zhe", "xi", "wang", "qu", "lv", "xing", "bi", "dao", "da", "zhong", "dian", "geng", "mei", "hao"]

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

$pinyin->convert('带着希望去旅行，比到达终点更美好', PINYIN_ASCII);
//["dai4","zhe","xi1","wang4","qu4","lv3","xing2","bi3","dao4","da2","zhong1","dian3","geng4","mei3","hao3"]
```

选项：

选项描述`PINYIN_NONE`不带音调输出: `mei hao``PINYIN_ASCII`带数字式音调： `mei3 hao3``PINYIN_UNICODE`UNICODE 式音调：`měi hǎo`### 生成用于链接的拼音字符串

[](#生成用于链接的拼音字符串)

```
$pinyin->permalink('带着希望去旅行'); // dai-zhe-xi-wang-qu-lv-xing
$pinyin->permalink('带着希望去旅行', '.'); // dai.zhe.xi.wang.qu.lv.xing
```

### 获取首字符字符串

[](#获取首字符字符串)

```
$pinyin->abbr('带着希望去旅行'); // dzxwqlx
$pinyin->abbr('带着希望去旅行', '-'); // d-z-x-w-q-l-x
```

### 翻译整段文字为拼音

[](#翻译整段文字为拼音)

将会保留中文字符：`，。 ！ ？ ： “ ” ‘ ’` 并替换为对应的英文符号。

```
$pinyin->sentence('带着希望去旅行，比到达终点更美好！');
// dai zhe xi wang qu lv xing, bi dao da zhong dian geng mei hao!

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

### 翻译姓名

[](#翻译姓名)

姓名的姓的读音有些与普通字不一样，比如 ‘单’ 常见的音为 `dan`，而作为姓的时候读 `shan`。

```
$pinyin->name('单某某'); // ['shan', 'mou', 'mou']
$pinyin->name('单某某', PINYIN_UNICODE); // ["shàn","mǒu","mǒu"]
```

参考
--

[](#参考)

- [详细参考资料](https://github.com/overtrue/pinyin-resources)

License
=======

[](#license)

MIT

写在最后
====

[](#写在最后)

参考了 [资料](https://github.com/overtrue/pinyin)写的demo, 不足之处烦请指正。

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2331d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82a206ab925f0c3d1ce465a0a534d29c8476d15c7bd5adadee1035d2e3a5371d?d=identicon)[alismall](/maintainers/alismall)

---

Top Contributors

[![aliSmallNo](https://avatars.githubusercontent.com/u/23272764?v=4)](https://github.com/aliSmallNo "aliSmallNo (2 commits)")

### Embed Badge

![Health badge](/badges/alismall-zplite/health.svg)

```
[![Health](https://phpackages.com/badges/alismall-zplite/health.svg)](https://phpackages.com/packages/alismall-zplite)
```

PHPackages © 2026

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